From 1e48fa46cc1a06f0013d74383b8fc41e0bf33ee3 Mon Sep 17 00:00:00 2001 From: Levente Nas Date: Thu, 7 Nov 2024 22:05:53 +0100 Subject: [PATCH 1/3] feat: add subpath handler for simplerouter --- unstable/simplerouter/router.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unstable/simplerouter/router.go b/unstable/simplerouter/router.go index 990a9aa..76eb866 100644 --- a/unstable/simplerouter/router.go +++ b/unstable/simplerouter/router.go @@ -136,6 +136,10 @@ func (rg *RouteGroup) Handle(method string, path string, handler http.Handler) { rg.HandleFunc(method, path, handler.ServeHTTP) } +func (rg *RouteGroup) HandleSubpath(path string, handler http.Handler) { + rg.mux.Handle(path, handler) +} + func (rg *RouteGroup) GET(path string, handler http.Handler) { rg.Handle(http.MethodGet, path, handler) } -- 2.49.1 From e24dc1b377e01247c60a28e3dda39bc5c22295ba Mon Sep 17 00:00:00 2001 From: Levente Nas Date: Fri, 8 Nov 2024 20:34:32 +0100 Subject: [PATCH 2/3] fix: call routegroup's register route directly in handle subpath --- unstable/simplerouter/router.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unstable/simplerouter/router.go b/unstable/simplerouter/router.go index 76eb866..10f25ac 100644 --- a/unstable/simplerouter/router.go +++ b/unstable/simplerouter/router.go @@ -136,8 +136,8 @@ func (rg *RouteGroup) Handle(method string, path string, handler http.Handler) { rg.HandleFunc(method, path, handler.ServeHTTP) } -func (rg *RouteGroup) HandleSubpath(path string, handler http.Handler) { - rg.mux.Handle(path, handler) +func (rg *RouteGroup) SubpathHandle(path string, handler http.Handler) { + rg.registerRoute("", path, handler.ServeHTTP) } func (rg *RouteGroup) GET(path string, handler http.Handler) { -- 2.49.1 From 3eb4d77b3ab8dc24c7e3382d5a695cc4c5a2a76e Mon Sep 17 00:00:00 2001 From: Levente Batuska Date: Sat, 9 Nov 2024 18:48:26 +0100 Subject: [PATCH 3/3] fix(SimpleRouter): use rg.Handle instead of rg.registerRoute --- unstable/simplerouter/router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unstable/simplerouter/router.go b/unstable/simplerouter/router.go index 10f25ac..d65ea54 100644 --- a/unstable/simplerouter/router.go +++ b/unstable/simplerouter/router.go @@ -137,7 +137,7 @@ func (rg *RouteGroup) Handle(method string, path string, handler http.Handler) { } func (rg *RouteGroup) SubpathHandle(path string, handler http.Handler) { - rg.registerRoute("", path, handler.ServeHTTP) + rg.Handle("", path, handler) } func (rg *RouteGroup) GET(path string, handler http.Handler) { -- 2.49.1