2020-09-03 23:26:04 +08:00
|
|
|
type (
|
2020-09-29 11:14:52 +08:00
|
|
|
addReq struct {
|
|
|
|
book string `form:"book"`
|
|
|
|
price int64 `form:"price"`
|
|
|
|
}
|
2020-09-03 23:26:04 +08:00
|
|
|
|
2020-09-29 11:14:52 +08:00
|
|
|
addResp struct {
|
|
|
|
ok bool `json:"ok"`
|
|
|
|
}
|
2020-09-03 23:26:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
2020-09-29 11:14:52 +08:00
|
|
|
checkReq struct {
|
|
|
|
book string `form:"book"`
|
|
|
|
}
|
2020-09-03 23:26:04 +08:00
|
|
|
|
2020-09-29 11:14:52 +08:00
|
|
|
checkResp struct {
|
|
|
|
found bool `json:"found"`
|
|
|
|
price int64 `json:"price"`
|
|
|
|
}
|
2020-09-03 23:26:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
service bookstore-api {
|
|
|
|
@server(
|
|
|
|
handler: AddHandler
|
|
|
|
)
|
2020-09-29 11:14:52 +08:00
|
|
|
get /add (addReq) returns (addResp)
|
2020-09-03 23:26:04 +08:00
|
|
|
|
|
|
|
@server(
|
|
|
|
handler: CheckHandler
|
|
|
|
)
|
2020-09-29 11:14:52 +08:00
|
|
|
get /check (checkReq) returns (checkResp)
|
2020-09-03 23:26:04 +08:00
|
|
|
}
|