server: Switch to custom mux
This commit is contained in:
parent
a1069f115e
commit
ab9998881b
13 changed files with 313 additions and 62 deletions
28
pkg/mux/path.go
Normal file
28
pkg/mux/path.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package mux
|
||||
|
||||
import (
|
||||
"path"
|
||||
)
|
||||
|
||||
// normalizePath normalizes the provided path.
|
||||
// It ensures that there is both a leading and trailing slash.
|
||||
func normalizePath(value string) string {
|
||||
value = path.Clean(value)
|
||||
if value != "/" {
|
||||
value = value + "/"
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// parentSegment returns the parent segment of the provided path
|
||||
// it assumes that normalizePath has been called on value.
|
||||
func parentSegment(value string) string {
|
||||
if value == "" || value == "/" {
|
||||
return "/"
|
||||
}
|
||||
parent := path.Dir(value[:len(value)-1])
|
||||
if parent != "/" {
|
||||
parent = parent + "/"
|
||||
}
|
||||
return parent
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue