|
|
|
|
55
|
}
|
55
|
}
|
56
|
|
56
|
|
57
|
switch ctx.Request.Method {
|
57
|
switch ctx.Request.Method {
|
58
|
- case http.MethodGet, http.MethodPut, http.MethodDelete, http.MethodHead, http.MethodPatch, http.MethodOptions:
|
|
|
|
|
58
|
+ case http.MethodGet, http.MethodHead, http.MethodOptions:
|
59
|
ctx.JSON(http.StatusOK, data)
|
59
|
ctx.JSON(http.StatusOK, data)
|
60
|
- case http.MethodPost:
|
|
|
|
|
60
|
+ case http.MethodPost, http.MethodPut, http.MethodPatch:
|
61
|
ctx.JSON(http.StatusCreated, data)
|
61
|
ctx.JSON(http.StatusCreated, data)
|
62
|
default:
|
62
|
default:
|
63
|
ctx.JSON(http.StatusBadRequest, HTTPError{Msg: fmt.Sprintf("unsupported request method %s", ctx.Request.Method)})
|
63
|
ctx.JSON(http.StatusBadRequest, HTTPError{Msg: fmt.Sprintf("unsupported request method %s", ctx.Request.Method)})
|