fix dynamic paths for chi
This commit is contained in:
parent
d2072fe777
commit
33063f992a
1 changed files with 11 additions and 0 deletions
|
|
@ -293,6 +293,17 @@ func formatRoute(path string) string {
|
|||
path = strings.ReplaceAll(path, "_", "/")
|
||||
path = strings.ReplaceAll(path, ".", "/")
|
||||
path = strings.ReplaceAll(path, "\\", "/")
|
||||
|
||||
parts := strings.Split(path, "/")
|
||||
|
||||
for i, part := range parts {
|
||||
if strings.HasPrefix(part, ":") {
|
||||
parts[i] = fmt.Sprintf("{%s}", part[1:])
|
||||
}
|
||||
}
|
||||
|
||||
path = strings.Join(parts, "/")
|
||||
|
||||
if path == "" {
|
||||
return "/"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue