Improved performance

This commit is contained in:
2024-03-14 19:22:39 +01:00
parent d89859010b
commit 8f135c1dcd
3 changed files with 10 additions and 7 deletions

View File

@ -41,10 +41,13 @@ func New() Server {
config: defaultConfig(),
handlers: []Handler{
func(c Context) error {
handler := c.(*ctx).server.router.LookupNoAlloc(c.Method(), c.Path(), c.(*ctx).addParameter)
ctx := c.(*ctx)
method := ctx.Method()
path := ctx.Path()
handler := ctx.server.router.LookupNoAlloc(method, path, ctx.addParameter)
if handler == nil {
return c.Status(http.StatusNotFound).String(http.StatusText(http.StatusNotFound))
return ctx.Status(http.StatusNotFound).String(http.StatusText(http.StatusNotFound))
}
return handler(c)