Successfully returning getItem response from item service

This commit is contained in:
Brandon Watson
2023-08-13 20:40:27 -05:00
parent 98796d96fd
commit 346d87f3d1
3 changed files with 37 additions and 13 deletions

View File

@ -9,17 +9,19 @@ import (
var _ = API("item", func() {
Title("Item Service")
Server("item", func() {
Host("localhost", func() {
URI("grpc://localhost:8082")
})
})
Host("localhost", func() {
URI("grpc://localhost:8082")
})
})
})
var _ = Service("item", func() {
Description("A GRPC back service that handles CRUD operations for the items that exist and their attributes")
Method("getItem", func() {
Payload(Int)
Payload(func() {
Field(1, "id", Int)
})
Result(Item)
Error("NotFound")
@ -53,7 +55,9 @@ var _ = Service("item", func() {
})
Method("deleteItem", func() {
Payload(Int)
Payload(func() {
Field(1, "id", Int)
})
Result(Empty)
Error("NotFound")
Error("BadRequest")
@ -64,4 +68,4 @@ var _ = Service("item", func() {
Response("BadRequest", CodeInvalidArgument)
})
})
})
})

View File

@ -18,7 +18,7 @@ func NewItem(logger *log.Logger) item.Service {
}
// GetItem implements getItem.
func (s *itemsrvc) GetItem(ctx context.Context, p int) (res *item.Item, err error) {
func (s *itemsrvc) GetItem(ctx context.Context, p *item.GetItemPayload) (res *item.Item, err error) {
res = &item.Item{}
s.logger.Print("item.getItem")
return
@ -39,7 +39,7 @@ func (s *itemsrvc) UpdateItem(ctx context.Context, p *item.Item) (res *item.Item
}
// DeleteItem implements deleteItem.
func (s *itemsrvc) DeleteItem(ctx context.Context, p int) (err error) {
func (s *itemsrvc) DeleteItem(ctx context.Context, p *item.DeleteItemPayload) (err error) {
s.logger.Print("item.deleteItem")
return
}