feat(adapter): add support for additional parameters in Adapter and Client structs
This commit is contained in:
@@ -23,6 +23,10 @@ func SubscribeHandler(svcCtx *svc.ServiceContext) func(c *gin.Context) {
|
||||
ua := c.GetHeader("User-Agent")
|
||||
req.UA = c.Request.Header.Get("User-Agent")
|
||||
req.Flag = c.Query("flag")
|
||||
req.Type = c.Query("type")
|
||||
// 获取所有查询参数
|
||||
req.Params = getQueryMap(c.Request)
|
||||
|
||||
if svcCtx.Config.Subscribe.PanDomain {
|
||||
domain := c.Request.Host
|
||||
domainArr := strings.Split(domain, ".")
|
||||
@@ -94,3 +98,14 @@ func RegisterSubscribeHandlers(router *gin.Engine, serverCtx *svc.ServiceContext
|
||||
}
|
||||
router.GET(path, SubscribeHandler(serverCtx))
|
||||
}
|
||||
|
||||
// GetQueryMap 将 http.Request 的查询参数转换为 map[string]string
|
||||
func getQueryMap(r *http.Request) map[string]string {
|
||||
result := make(map[string]string)
|
||||
for k, v := range r.URL.Query() {
|
||||
if len(v) > 0 {
|
||||
result[k] = v[0]
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user