diff --git a/lib/core/utils/ctx/ctx.go b/lib/core/utils/ctx/ctx.go index fefb6b4c..723dd808 100644 --- a/lib/core/utils/ctx/ctx.go +++ b/lib/core/utils/ctx/ctx.go @@ -17,8 +17,8 @@ import ( "golang.org/x/text/language" ) -// Param 地址栏参数{id} -func Param(r *http.Request, key string) string { +// GetParam 地址栏参数{id} +func GetParam(r *http.Request, key string) string { vars := mux.Vars(r) v, ok := vars[key] if ok { @@ -47,7 +47,7 @@ func QueryMap(r *http.Request) map[string]any { return queryParams } -// ShouldBindQuery 查询参数读取json请求结构团体 +// ShouldBindQuery 查询参数读取json请求结构团体 &xxx func ShouldBindQuery(r *http.Request, args any) error { queryParams := QueryMap(r) body, err := json.Marshal(queryParams) @@ -57,7 +57,7 @@ func ShouldBindQuery(r *http.Request, args any) error { return json.Unmarshal(body, args) } -// 读取json请求结构团体 +// ShouldBindJSON 读取json请求结构团体 &xxx func ShouldBindJSON(r *http.Request, args any) error { body, err := io.ReadAll(io.LimitReader(r.Body, 1<<20)) // 设置较大的长度,例如 1<<20 (1MB) if err != nil { diff --git a/lib/midware/mml_log.go b/lib/midware/mml_log.go index 91711477..1295c5e7 100644 --- a/lib/midware/mml_log.go +++ b/lib/midware/mml_log.go @@ -36,7 +36,7 @@ func LogMML(next http.Handler) http.Handler { // 收尾存入数据库的参数 mmlCmd := bodyArgs["mml"].([]any)[0] ipAddr := strings.Split(r.RemoteAddr, ":")[0] - neType := ctx.Param(r, "elementTypeValue") + neType := ctx.GetParam(r, "elementTypeValue") neId := ctx.GetQuery(r, "ne_id") timeStr := date.ParseDateToStr(time.Now(), date.YYYY_MM_DD_HH_MM_SS)