167 lines
3.0 KiB
Go
167 lines
3.0 KiB
Go
package design
|
|
|
|
import (
|
|
. "crossnokaye-interview-assignment/design"
|
|
|
|
. "goa.design/goa/v3/dsl"
|
|
)
|
|
|
|
var _ = API("front", func() {
|
|
Title("API Front Service")
|
|
Description("An HTTP/JSON front service which provides an API to manipulate the Characters, their inventories, and the Items that exist")
|
|
Server("front", func() {
|
|
Host("localhost", func() {
|
|
URI("http://localhost:8000")
|
|
})
|
|
})
|
|
})
|
|
|
|
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)
|
|
Result(Item)
|
|
Error("NotFound")
|
|
|
|
HTTP(func() {
|
|
GET("/item/{id}")
|
|
Response(StatusOK)
|
|
Response(StatusBadRequest)
|
|
Response(StatusNotFound)
|
|
})
|
|
})
|
|
|
|
// Method("listItems", func() {
|
|
// })
|
|
|
|
Method("createItem", func() {
|
|
Payload(Item)
|
|
Result(Item)
|
|
Error("BadRequest")
|
|
|
|
HTTP(func() {
|
|
POST("/item")
|
|
Response(StatusOK)
|
|
Response(StatusBadRequest)
|
|
})
|
|
})
|
|
|
|
Method("updateItem", func() {
|
|
Payload(Item)
|
|
Result(Item)
|
|
Error("NotFound")
|
|
Error("BadRequest")
|
|
|
|
HTTP(func() {
|
|
PUT("/item/{id}")
|
|
Response(StatusOK)
|
|
Response(StatusBadRequest)
|
|
Response(StatusNotFound)
|
|
})
|
|
})
|
|
|
|
Method("deleteItem", func() {
|
|
Payload(Int)
|
|
Result(Empty)
|
|
Error("NotFound")
|
|
Error("BadRequest")
|
|
|
|
HTTP(func() {
|
|
POST("/item/{id}")
|
|
Response(StatusOK)
|
|
Response(StatusBadRequest)
|
|
Response(StatusNotFound)
|
|
})
|
|
})
|
|
|
|
Method("getCharacter", func() {
|
|
Payload(Int)
|
|
Result(Character)
|
|
Error("NotFound")
|
|
Error("BadRequest")
|
|
|
|
HTTP(func() {
|
|
GET("/character/{id}")
|
|
Response(StatusOK)
|
|
Response(StatusBadRequest)
|
|
Response(StatusNotFound)
|
|
})
|
|
})
|
|
|
|
// Method("listCharacters", func() {
|
|
// })
|
|
|
|
Method("createCharacter", func() {
|
|
Payload(Character)
|
|
Result(Character)
|
|
Error("BadRequest")
|
|
Error("NotFound")
|
|
|
|
HTTP(func() {
|
|
POST("/character")
|
|
Body(Character)
|
|
Response(StatusBadRequest)
|
|
Response(StatusOK)
|
|
Response(StatusInternalServerError)
|
|
})
|
|
})
|
|
|
|
Method("updateCharacter", func() {
|
|
Payload(Character)
|
|
Result(Character)
|
|
Error("NotFound")
|
|
Error("BadRequest")
|
|
|
|
HTTP(func() {
|
|
PUT("/character/{id}")
|
|
Body(Character)
|
|
Response(StatusOK)
|
|
Response(StatusBadRequest)
|
|
Response(StatusNotFound)
|
|
})
|
|
})
|
|
|
|
Method("deleteCharacter", func() {
|
|
Payload(Int)
|
|
Result(Empty)
|
|
Error("NotFound")
|
|
Error("BadRequest")
|
|
|
|
HTTP(func() {
|
|
POST("/character/{id}")
|
|
Response(StatusOK)
|
|
Response(StatusBadRequest)
|
|
Response(StatusNotFound)
|
|
})
|
|
})
|
|
|
|
Method("addItemToInventory", func() {
|
|
Payload(Int)
|
|
Result(Empty)
|
|
Error("NotFound")
|
|
Error("BadRequest")
|
|
|
|
HTTP(func() {
|
|
POST("/inventory/{CharacterId}")
|
|
Response(StatusOK)
|
|
Response(StatusBadRequest)
|
|
})
|
|
})
|
|
|
|
Method("removeItemFromInventory", func() {
|
|
Payload(Int)
|
|
Result(Empty)
|
|
Error("NotFound")
|
|
Error("BadRequest")
|
|
|
|
HTTP(func() {
|
|
PUT("/inventory/{CharacterId}")
|
|
Response(StatusOK)
|
|
Response(StatusBadRequest)
|
|
})
|
|
})
|
|
|
|
Files("/openapi.json", "./gen/http/openapi.json")
|
|
})
|