@@ -26,6 +26,40 @@ const (
2626 None AuthType = "None"
2727)
2828
29+ func parseTypedQuery (q url.Values ) map [string ]interface {} {
30+ result := make (map [string ]interface {})
31+
32+ for key , values := range q {
33+ if ! strings .HasPrefix (key , "@" ) {
34+ continue
35+ }
36+
37+ cleanKey := strings .TrimPrefix (key , "@" )
38+ raw := values [0 ]
39+
40+ intValue , err := strconv .Atoi (raw )
41+
42+ if strings .Contains (raw , "," ) {
43+ parts := strings .Split (raw , "," )
44+ var list []interface {}
45+ for _ , part := range parts {
46+ if intVal , err := strconv .Atoi (part ); err == nil {
47+ list = append (list , intVal )
48+ } else {
49+ list = append (list , part )
50+ }
51+ }
52+ result [cleanKey ] = list
53+ } else if err == nil {
54+ result [cleanKey ] = intValue
55+ } else {
56+ result [cleanKey ] = raw
57+ }
58+ }
59+
60+ return result
61+ }
62+
2963func getAuthType (str string ) AuthType {
3064 switch str {
3165 case "Bearer" :
@@ -169,20 +203,10 @@ func TemplatingMiddleware(next http.Handler, VARIABLES map[string]string) http.H
169203
170204 query , _ := renderTemplate ("query" , req .URL .RawQuery , VARIABLES )
171205
172- queryData , _ := url .ParseQuery (query )
173-
174206 modifiedQuery := req .URL .Query ()
175207
176- for key , value := range queryData {
177- keyWithoutPrefix , found := strings .CutPrefix (key , "@" )
178-
179- if found {
180- modifiedBodyData [keyWithoutPrefix ] = value
181-
182- modifiedQuery .Del (key )
183- }
184- }
185-
208+ modifiedBodyData = parseTypedQuery (modifiedQuery )
209+
186210 req .URL .RawQuery = modifiedQuery .Encode ()
187211
188212 modifiedBodyBytes , err = json .Marshal (modifiedBodyData )
0 commit comments