Using generated error types
This commit is contained in:
@ -27,8 +27,7 @@ var _ = Service("front", func() {
|
||||
HTTP(func() {
|
||||
GET("/item/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
@ -39,20 +38,18 @@ var _ = Service("front", func() {
|
||||
HTTP(func() {
|
||||
GET("/item")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
Method("createItem", func() {
|
||||
Payload(Item)
|
||||
Result(Item)
|
||||
Error("BadRequest")
|
||||
Error("AlreadyExists")
|
||||
|
||||
HTTP(func() {
|
||||
POST("/item")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response("AlreadyExists", StatusConflict)
|
||||
})
|
||||
})
|
||||
|
||||
@ -60,13 +57,11 @@ var _ = Service("front", func() {
|
||||
Payload(Item)
|
||||
Result(Item)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
PUT("/item/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
@ -74,13 +69,11 @@ var _ = Service("front", func() {
|
||||
Payload(String)
|
||||
Result(Empty)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
DELETE("/item/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
@ -88,13 +81,11 @@ var _ = Service("front", func() {
|
||||
Payload(String)
|
||||
Result(Character)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
GET("/character/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
@ -105,22 +96,18 @@ var _ = Service("front", func() {
|
||||
HTTP(func() {
|
||||
GET("/character")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
Method("createCharacter", func() {
|
||||
Payload(Character)
|
||||
Result(Character)
|
||||
Error("BadRequest")
|
||||
Error("NotFound")
|
||||
|
||||
HTTP(func() {
|
||||
POST("/character")
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusOK)
|
||||
Response(StatusInternalServerError)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
@ -128,13 +115,11 @@ var _ = Service("front", func() {
|
||||
Payload(Character)
|
||||
Result(Character)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
PUT("/character/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
@ -142,13 +127,11 @@ var _ = Service("front", func() {
|
||||
Payload(String)
|
||||
Result(Empty)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
DELETE("/character/{name}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
@ -156,12 +139,11 @@ var _ = Service("front", func() {
|
||||
Payload(InventoryRecord)
|
||||
Result(Empty)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
POST("/character/{characterName}/item")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
@ -169,12 +151,11 @@ var _ = Service("front", func() {
|
||||
Payload(InventoryRecord)
|
||||
Result(Empty)
|
||||
Error("NotFound")
|
||||
Error("BadRequest")
|
||||
|
||||
HTTP(func() {
|
||||
DELETE("/character/{characterName}/item/{itemName}")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
@ -183,12 +164,12 @@ var _ = Service("front", func() {
|
||||
Field(1, "characterName", String)
|
||||
})
|
||||
Result(ArrayOf(Item))
|
||||
Error("NotFound")
|
||||
|
||||
HTTP(func() {
|
||||
GET("/character/{characterName}/item")
|
||||
Response(StatusOK)
|
||||
Response(StatusBadRequest)
|
||||
Response(StatusNotFound)
|
||||
Response("NotFound", StatusNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user