mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-02-05 07:37:02 +01:00
update to include JSON indicating request already handled
This commit is contained in:
parent
fd2be943b7
commit
53fcea5751
1 changed files with 13 additions and 1 deletions
|
@ -32,6 +32,14 @@
|
|||
// https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/
|
||||
func Idempotency() gin.HandlerFunc {
|
||||
|
||||
// Prepare response given when request already handled.
|
||||
alreadyHandled, err := json.Marshal(map[string]string{
|
||||
"status": "request already handled",
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Prepare expected error response JSON ahead of time.
|
||||
errorConflict, err := json.Marshal(map[string]string{
|
||||
"error": "request already under way",
|
||||
|
@ -96,7 +104,11 @@ func Idempotency() gin.HandlerFunc {
|
|||
// Already handled
|
||||
// this request.
|
||||
default:
|
||||
c.Status(code)
|
||||
apiutil.Data(c,
|
||||
code,
|
||||
apiutil.AppJSON,
|
||||
alreadyHandled,
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue