Skip to content

Commit

Permalink
fix: go through globalHandlers before matching route
Browse files Browse the repository at this point in the history
  • Loading branch information
sheey11 committed May 26, 2024
1 parent 21dc38b commit 31c9100
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,12 @@ export class Router<Env = any, CtxExt = {}, ReqExt = {}> {

const route = this.getRoute(req)

if (!route)
const routeHandler = route ? route.handlers : []
const notFoundHandler: RouterHandler<Env, CtxExt, ReqExt> = () => {
return new Response(this.debugMode ? 'Route not found!' : null, { status: 404 })
}

const handlers = [...this.globalHandlers, ...route.handlers]
const handlers = [...this.globalHandlers, ...routeHandler, notFoundHandler]
const dbg = this.debugMode

let response: Response | undefined
Expand Down

0 comments on commit 31c9100

Please sign in to comment.