From 09b4dbb321667f80304336e26e85fe0e970d0425 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Sat, 15 Jun 2024 16:36:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mux=E4=B8=8A=E4=B8=8B=E6=96=87=E5=B7=A5?= =?UTF-8?q?=E5=85=B7ctx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/utils/ctx/ctx.go | 8 ++++---- lib/midware/mml_log.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) 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)