Updating resources according to instructions
This commit is contained in:
@ -20,12 +20,12 @@ var _ = Service("front", func() {
|
||||
Description("A GRPC back service that handles CRUD operations for the Items that exist and their attributes")
|
||||
|
||||
Method("getItem", func() {
|
||||
Payload(Int)
|
||||
Payload(String)
|
||||
Result(Item)
|
||||
Error("NotFound")
|
||||
|
||||
HTTP(func() {
|
||||
GET("/item/{id}")
|
||||
GET("/item/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
@ -63,7 +63,7 @@ var _ = Service("front", func() {
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
PUT("/item/{id}")
|
||||
PUT("/item/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
@ -71,13 +71,13 @@ var _ = Service("front", func() {
|
||||
})
|
||||
|
||||
Method("deleteItem", func() {
|
||||
Payload(Int)
|
||||
Payload(String)
|
||||
Result(Empty)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
DELETE("/item/{id}")
|
||||
DELETE("/item/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
@ -85,13 +85,13 @@ var _ = Service("front", func() {
|
||||
})
|
||||
|
||||
Method("getCharacter", func() {
|
||||
Payload(Int)
|
||||
Payload(String)
|
||||
Result(Character)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
GET("/character/{id}")
|
||||
GET("/character/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
@ -131,7 +131,7 @@ var _ = Service("front", func() {
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
PUT("/character/{id}")
|
||||
PUT("/character/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
@ -139,13 +139,13 @@ var _ = Service("front", func() {
|
||||
})
|
||||
|
||||
Method("deleteCharacter", func() {
|
||||
Payload(Int)
|
||||
Payload(String)
|
||||
Result(Empty)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
DELETE("/character/{id}")
|
||||
DELETE("/character/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
@ -159,7 +159,7 @@ var _ = Service("front", func() {
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
POST("/character/{characterId}/item")
|
||||
POST("/character/{characterName}/item")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
})
|
||||
@ -172,7 +172,7 @@ var _ = Service("front", func() {
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
DELETE("/character/{characterId}/item/{itemId}")
|
||||
DELETE("/character/{characterName}/item/{itemName}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
})
|
||||
@ -180,12 +180,12 @@ var _ = Service("front", func() {
|
||||
|
||||
Method("listInventoryItems", func() {
|
||||
Payload(func() {
|
||||
Field(1, "characterId", Int)
|
||||
Field(1, "characterName", String)
|
||||
})
|
||||
Result(ArrayOf(Item))
|
||||
|
||||
HTTP(func() {
|
||||
GET("/character/{characterId}/item")
|
||||
GET("/character/{characterName}/item")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
|
@ -75,9 +75,9 @@ func NewFront(logger *log.Logger, itemClientConnection *grpc.ClientConn, charact
|
||||
}
|
||||
|
||||
// GetItem implements getItem.
|
||||
func (s *frontsrvc) GetItem(ctx context.Context, id int) (res *front.Item, err error) {
|
||||
func (s *frontsrvc) GetItem(ctx context.Context, name string) (res *front.Item, err error) {
|
||||
s.logger.Print("front.getItem")
|
||||
getItemResponse, err := s.itemClient.getItem(ctx, &genItem.GetItemPayload{ID: &id})
|
||||
getItemResponse, err := s.itemClient.getItem(ctx, &genItem.GetItemPayload{Name: &name})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -127,9 +127,9 @@ func (s *frontsrvc) UpdateItem(ctx context.Context, p *front.Item) (res *front.I
|
||||
}
|
||||
|
||||
// DeleteItem implements deleteItem.
|
||||
func (s *frontsrvc) DeleteItem(ctx context.Context, p int) (err error) {
|
||||
func (s *frontsrvc) DeleteItem(ctx context.Context, p string) (err error) {
|
||||
s.logger.Print("front.deleteItem")
|
||||
_, err = s.itemClient.deleteItem(ctx, &genItem.DeleteItemPayload{ID: &p})
|
||||
_, err = s.itemClient.deleteItem(ctx, &genItem.DeleteItemPayload{Name: &p})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -138,9 +138,9 @@ func (s *frontsrvc) DeleteItem(ctx context.Context, p int) (err error) {
|
||||
}
|
||||
|
||||
// GetCharacter implements getCharacter.
|
||||
func (s *frontsrvc) GetCharacter(ctx context.Context, id int) (res *front.Character, err error) {
|
||||
func (s *frontsrvc) GetCharacter(ctx context.Context, name string) (res *front.Character, err error) {
|
||||
s.logger.Print("front.getCharacter")
|
||||
getCharacterResponse, err := s.characterClient.getCharacter(ctx, &genCharacter.GetCharacterPayload{ID: &id})
|
||||
getCharacterResponse, err := s.characterClient.getCharacter(ctx, &genCharacter.GetCharacterPayload{Name: &name})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -191,10 +191,10 @@ func (s *frontsrvc) UpdateCharacter(ctx context.Context, p *front.Character) (re
|
||||
}
|
||||
|
||||
// DeleteCharacter implements deleteCharacter.
|
||||
func (s *frontsrvc) DeleteCharacter(ctx context.Context, p int) (err error) {
|
||||
func (s *frontsrvc) DeleteCharacter(ctx context.Context, name string) (err error) {
|
||||
s.logger.Print("front.deleteCharacter")
|
||||
|
||||
_, err = s.characterClient.deleteCharacter(ctx, &genCharacter.DeleteCharacterPayload{ID: &p})
|
||||
_, err = s.characterClient.deleteCharacter(ctx, &genCharacter.DeleteCharacterPayload{Name: &name})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user