1
0

add dbg to handler context

This commit is contained in:
2023-02-02 18:37:28 +01:00
parent f3181ca9a5
commit bcab122e15

View File

@@ -23,6 +23,7 @@ export type Route<TEnv, TExt> = {
export type RouterContext<TEnv = any, TExt = any> = { export type RouterContext<TEnv = any, TExt = any> = {
env: TEnv env: TEnv
req: RouterRequest<TExt> req: RouterRequest<TExt>
dbg: boolean
ctx?: ExecutionContext ctx?: ExecutionContext
} }
@@ -402,11 +403,12 @@ export class Router<TEnv = any, TExt = any> {
} }
const handlers = [...this.globalHandlers, ...route.handlers] const handlers = [...this.globalHandlers, ...route.handlers]
const dbg = this.debugMode
let response: Response | undefined let response: Response | undefined
for (const handler of handlers) { for (const handler of handlers) {
const res = await handler({ env, req, ctx }) const res = await handler({ env, req, dbg, ctx })
if (res) { if (res) {
response = res response = res