feat: standardize transport contracts across Gin and nethttp

This commit is contained in:
2026-09-21 00:10:44 +08:00
parent affd02d5f7
commit 5561795d80
22 changed files with 1137 additions and 205 deletions

View File

@@ -28,6 +28,12 @@ func (a *App) adapt(handler httpx.Handler, middleware ...httpx.Middleware) http.
})
}
// Handle registers an explicit method, including HEAD, OPTIONS and extension
// methods, through the same business middleware and error handling as GET.
func (a *App) Handle(method, path string, handler httpx.Handler, middleware ...httpx.Middleware) {
a.handle(a.router, method, path, handler, middleware)
}
func (a *App) GET(path string, handler httpx.Handler, middleware ...httpx.Middleware) {
a.handle(a.router, http.MethodGet, path, handler, middleware)
}
@@ -80,6 +86,11 @@ func (g *RouterGroup) route(method, path string, handler httpx.Handler, middlewa
g.app.handle(g.group, method, path, handler, combined)
}
// Handle registers an explicit method within this group's middleware chain.
func (g *RouterGroup) Handle(method, path string, handler httpx.Handler, middleware ...httpx.Middleware) {
g.route(method, path, handler, middleware)
}
func (g *RouterGroup) GET(path string, handler httpx.Handler, middleware ...httpx.Middleware) {
g.route(http.MethodGet, path, handler, middleware)
}