Skip to content

Commit 052c286

Browse files
committed
自动处理path 后缀
1 parent 4ef6d73 commit 052c286

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

router/data.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ func (rs *routerData) Parse() (*http.ServeMux, error) {
2323
}
2424
tmpSet[path] = struct{}{}
2525

26-
mux.Handle(path, v.Router)
26+
if !strings.HasSuffix(v.Path, "/") {
27+
mux.Handle(path, v.Router)
28+
}
29+
2730
mux.Handle(fmt.Sprint(path, "/"), v.Router)
2831
}
2932
return mux, nil

0 commit comments

Comments
 (0)