Skip to content

Commit f955489

Browse files
committed
fix #2215
1 parent e7b4039 commit f955489

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/router/api_builder.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@ func (api *APIBuilder) Handle(method string, relativePath string, handlers ...co
544544
// handle registers a full route to this Party.
545545
// Use Handle or Get, Post, Put, Delete and et.c. instead.
546546
func (api *APIBuilder) handle(errorCode int, method string, relativePath string, handlers ...context.Handler) *Route {
547+
if relativePath == "" {
548+
relativePath = "/"
549+
}
550+
547551
routes := api.createRoutes(errorCode, []string{method}, relativePath, handlers...)
548552

549553
var route *Route // the last one is returned.
@@ -832,6 +836,10 @@ func removeDuplicates(elements []string) (result []string) {
832836
// use the `Subdomain` or `WildcardSubdomain` methods
833837
// or pass a "relativePath" of "admin." or "*." respectfully.
834838
func (api *APIBuilder) Party(relativePath string, handlers ...context.Handler) Party {
839+
if relativePath == "" {
840+
relativePath = "/"
841+
}
842+
835843
// if app.Party("/"), root party or app.Party("/user") == app.Party("/user")
836844
// then just add the middlewares and return itself.
837845
// if relativePath == "" || api.relativePath == relativePath {

0 commit comments

Comments
 (0)