|
|
@ -28,13 +28,16 @@ func EncodeURL(pathTemplate string, msg proto.Message, needQuery bool) string { |
|
|
|
} |
|
|
|
} |
|
|
|
key := in[2 : len(in)-1] |
|
|
|
key := in[2 : len(in)-1] |
|
|
|
vars := strings.Split(key, ".") |
|
|
|
vars := strings.Split(key, ".") |
|
|
|
if value, err := getValueByField(msg.ProtoReflect(), vars); err == nil { |
|
|
|
value, err := getValueByField(msg.ProtoReflect(), vars) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return in |
|
|
|
|
|
|
|
} |
|
|
|
pathParams[key] = struct{}{} |
|
|
|
pathParams[key] = struct{}{} |
|
|
|
return "/" + value |
|
|
|
return "/" + value |
|
|
|
} |
|
|
|
|
|
|
|
return in |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
if needQuery { |
|
|
|
if !needQuery { |
|
|
|
|
|
|
|
return path |
|
|
|
|
|
|
|
} |
|
|
|
u, err := form.EncodeValues(msg) |
|
|
|
u, err := form.EncodeValues(msg) |
|
|
|
if err == nil && len(u) > 0 { |
|
|
|
if err == nil && len(u) > 0 { |
|
|
|
for key := range pathParams { |
|
|
|
for key := range pathParams { |
|
|
@ -45,7 +48,6 @@ func EncodeURL(pathTemplate string, msg proto.Message, needQuery bool) string { |
|
|
|
path += "?" + query |
|
|
|
path += "?" + query |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return path |
|
|
|
return path |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|