Skip to content

Commit

Permalink
Fix: 204 on unknown OPG
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky authored and m-kus committed Mar 11, 2021
1 parent d7f4f46 commit f6f26f9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/api/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,12 @@ var doc = `{
}
}
},
"204": {
"description": "No Content",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
Expand Down
6 changes: 6 additions & 0 deletions cmd/api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,12 @@
}
}
},
"204": {
"description": "No Content",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
Expand Down
4 changes: 4 additions & 0 deletions cmd/api/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2636,6 +2636,10 @@ paths:
items:
$ref: '#/definitions/handlers.Operation'
type: array
"204":
description: No Content
schema:
$ref: '#/definitions/gin.H'
"400":
description: Bad Request
schema:
Expand Down
6 changes: 6 additions & 0 deletions cmd/api/handlers/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func (ctx *Context) GetContractOperations(c *gin.Context) {
// @Accept json
// @Produce json
// @Success 200 {array} Operation
// @Success 204 {object} gin.H
// @Failure 400 {object} Error
// @Failure 500 {object} Error
// @Router /v1/opg/{hash} [get]
Expand Down Expand Up @@ -114,6 +115,11 @@ func (ctx *Context) GetOperation(c *gin.Context) {
}
}

if len(op) == 0 {
c.JSON(http.StatusNoContent, gin.H{})
return
}

c.JSON(http.StatusOK, opg)
return
}
Expand Down

0 comments on commit f6f26f9

Please sign in to comment.