1
0

add bearer helper function

This commit is contained in:
2023-02-02 20:37:58 +01:00
parent d4ba12a517
commit b0d05656bb

View File

@@ -48,6 +48,7 @@ export type RouterRequest<TExt> = {
body: string | any
raw: Request
cf?: IncomingRequestCfProperties
bearer: () => string
} & TExt
/**
@@ -387,7 +388,8 @@ export class Router<TEnv = any, TExt = any> {
raw: request,
params: {},
query: {},
body: ''
body: '',
bearer: () => request.headers.get('Authorization')?.replace('Bearer ', '').trim() ?? '',
} as RouterRequest<TExt>
const route = this.getRoute(req)