反向代理支持RequestPath、RequestURI等

This commit is contained in:
GoEdgeLab
2020-09-27 10:02:54 +08:00
parent 6c79fb1d3f
commit 47a1a477f3
5 changed files with 129 additions and 7 deletions

24
internal/utils/path.go Normal file
View File

@@ -0,0 +1,24 @@
package utils
// 清理Path中的多余的字符
func CleanPath(path string) string {
l := len(path)
if l == 0 {
return "/"
}
result := []byte{'/'}
isSlash := true
for i := 0; i < l; i++ {
if path[i] == '\\' || path[i] == '/' {
if !isSlash {
isSlash = true
result = append(result, '/')
}
} else {
isSlash = false
result = append(result, path[i])
}
}
return string(result)
}