templates: Add a proper menu and navigation
This commit is contained in:
parent
0bb7f99fa3
commit
a00195be16
76 changed files with 336 additions and 233 deletions
|
|
@ -52,7 +52,7 @@ func (mux *Mux[T]) Add(path string, predicate Predicate, exact bool, h http.Hand
|
|||
mux.prefixes = make(map[string][]handler)
|
||||
}
|
||||
|
||||
mPath := normalizePath(path)
|
||||
mPath := NormalizePath(path)
|
||||
mHandler := handler{Predicate: predicate, Handler: h}
|
||||
if exact {
|
||||
mux.exacts[mPath] = append(mux.exacts[mPath], mHandler)
|
||||
|
|
@ -71,7 +71,7 @@ func (mux *Mux[T]) Match(r *http.Request, prepare bool) (http.Handler, bool) {
|
|||
r = mux.Prepare(r)
|
||||
}
|
||||
|
||||
candidate := normalizePath(r.URL.Path)
|
||||
candidate := NormalizePath(r.URL.Path)
|
||||
|
||||
// match the exact path first
|
||||
for _, h := range mux.exacts[candidate] {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import (
|
|||
"path"
|
||||
)
|
||||
|
||||
// normalizePath normalizes the provided path.
|
||||
// NormalizePath normalizes the provided path.
|
||||
// It ensures that there is both a leading and trailing slash.
|
||||
func normalizePath(value string) string {
|
||||
func NormalizePath(value string) string {
|
||||
value = path.Clean(value)
|
||||
if value != "/" {
|
||||
value = value + "/"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue