Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
fix URL Prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Xu Dongyan committed Feb 19, 2023
1 parent b57885c commit 1d9cb12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ func New(opts Options) *App {
routes: RouteList{},
children: []*App{},

RouteNamer: baseRouteNamer{},
RouteNamer: baseRouteNamer{
Prefix: opts.Prefix,
},
}
a.Home.app = a // replace root.
a.Home.appSelf = a // temporary, reverse reference to the group app.
Expand Down
6 changes: 4 additions & 2 deletions routenamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ type RouteNamer interface {
}

// BaseRouteNamer is the default route namer used by apps.
type baseRouteNamer struct{}
type baseRouteNamer struct {
Prefix string
}

func (drn baseRouteNamer) NameRoute(p string) string {
if p == "/" || p == "" {
if p == drn.Prefix || p == "/" || p == "" {
return "root"
}

Expand Down

0 comments on commit 1d9cb12

Please sign in to comment.