-
Notifications
You must be signed in to change notification settings - Fork 0
/
route_updatedenoms.go
41 lines (33 loc) · 1014 Bytes
/
route_updatedenoms.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package rest
import (
"net/http"
models "github.com/emerishq/demeris-backend-models/cns"
"github.com/gin-gonic/gin"
)
const updateDenomsRoute = "/denoms"
type updateDenomsRequest struct {
Chain string `json:"chain_name"`
Denoms models.DenomList `json:"denoms"`
}
// @Summary Update the denominations for a chain
// @Description Update the primary channel handler for a chain
// @Router /denoms [post]
// @Param chain body updateDenomsRequest true "Chain data to update"
// @Accept json
// @Produce json
// @Success 200
// @Failure 400 "if cannot parse payload"
// @Failure 500
func (r *router) updateDenomsHandler(ctx *gin.Context) {
req := updateDenomsRequest{}
if err := ctx.BindJSON(&req); err != nil {
e(ctx, http.StatusBadRequest, err)
r.s.l.Error("cannot bind json to updateDenomsRequest", err)
return
}
if err := r.s.DB.UpdateDenoms(req.Chain, req.Denoms); err != nil {
e(ctx, http.StatusInternalServerError, err)
r.s.l.Error("cannot update denoms", err)
return
}
}