|
|
@ -28,22 +28,24 @@ 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) |
|
|
|
pathParams[key] = struct{}{} |
|
|
|
if err != nil { |
|
|
|
return "/" + value |
|
|
|
return in |
|
|
|
} |
|
|
|
} |
|
|
|
return in |
|
|
|
pathParams[key] = struct{}{} |
|
|
|
|
|
|
|
return "/" + value |
|
|
|
}) |
|
|
|
}) |
|
|
|
if needQuery { |
|
|
|
if !needQuery { |
|
|
|
u, err := form.EncodeValues(msg) |
|
|
|
return path |
|
|
|
if err == nil && len(u) > 0 { |
|
|
|
} |
|
|
|
for key := range pathParams { |
|
|
|
u, err := form.EncodeValues(msg) |
|
|
|
delete(u, key) |
|
|
|
if err == nil && len(u) > 0 { |
|
|
|
} |
|
|
|
for key := range pathParams { |
|
|
|
query := u.Encode() |
|
|
|
delete(u, key) |
|
|
|
if query != "" { |
|
|
|
} |
|
|
|
path += "?" + query |
|
|
|
query := u.Encode() |
|
|
|
} |
|
|
|
if query != "" { |
|
|
|
|
|
|
|
path += "?" + query |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return path |
|
|
|
return path |
|
|
|