MCPcopy Index your code
hub / github.com/53AI/53AIHub / unpdatePath

Function unpdatePath

api/middleware/request_decoder.go:80–107  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

78}
79
80func unpdatePath(c *gin.Context) {
81 // 当路由存在约定的ID参数名时,尝试解码并回填
82 params := c.Params
83 updated := false
84
85 for i := range params {
86 name := params[i].Key
87 val := params[i].Value
88
89 // 按约定判断是否为ID参数(如 id、file_id、library_id 等)
90 if hashids.IsIDParam(name) {
91 if decoded, err := hashids.TryParseID(val); err == nil {
92 // 将解码后的数值ID写回到路由参数
93 params[i].Value = strconv.FormatInt(decoded, 10)
94 // 同时在上下文中保存,便于后续处理函数直接获取
95 c.Set("decoded_"+name, decoded)
96 updated = true
97
98 // 日志记录
99 logger.SysLogf("RequestDecoder: decoded route param '%s' %q -> %d", name, val, decoded)
100 }
101 }
102 }
103
104 if updated {
105 c.Params = params
106 }
107}
108
109func updateQuery(c *gin.Context) {
110 // 当查询参数存在约定的ID参数名时,尝试解码并回填

Callers 1

RequestDecoderFunction · 0.85

Calls 2

IsIDParamMethod · 0.80
SetMethod · 0.80

Tested by

no test coverage detected