From 1d9cb124743786e892fed764c41d18d38dab97bb Mon Sep 17 00:00:00 2001 From: Xu Dongyan Date: Sun, 19 Feb 2023 12:14:59 +0800 Subject: [PATCH] fix URL Prefix --- app.go | 4 +++- routenamer.go | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app.go b/app.go index ebcb90525..0ed5f9f2c 100644 --- a/app.go +++ b/app.go @@ -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. diff --git a/routenamer.go b/routenamer.go index b6d28058d..8b2dd295b 100644 --- a/routenamer.go +++ b/routenamer.go @@ -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" }