平替ShouldBindJSON
This commit is contained in:
@@ -186,7 +186,7 @@ func Config(w http.ResponseWriter, r *http.Request) {
|
|||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
err := services.JSONBody(r, &bodyArgs)
|
err := services.ShouldBindJSON(r, &bodyArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("io.ReadAll is failed:", err)
|
log.Error("io.ReadAll is failed:", err)
|
||||||
services.ResponseNotFound404UriNotExist(w, r)
|
services.ResponseNotFound404UriNotExist(w, r)
|
||||||
@@ -292,7 +292,7 @@ func TopOps(w http.ResponseWriter, r *http.Request) {
|
|||||||
Ops string `json:"ops"`
|
Ops string `json:"ops"`
|
||||||
Pid string `json:"pid"`
|
Pid string `json:"pid"`
|
||||||
}
|
}
|
||||||
err := services.JSONBody(r, &bodyArgs)
|
err := services.ShouldBindJSON(r, &bodyArgs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("io.ReadAll is failed:", err)
|
log.Error("io.ReadAll is failed:", err)
|
||||||
services.ResponseNotFound404UriNotExist(w, r)
|
services.ResponseNotFound404UriNotExist(w, r)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 读取json请求结构团体
|
// 读取json请求结构团体
|
||||||
func JSONBody(r *http.Request, args any) error {
|
func ShouldBindJSON(r *http.Request, args any) error {
|
||||||
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user