From b0d05656bb4ff206d5699a10a30013d8c4a9c2cf Mon Sep 17 00:00:00 2001 From: Toby Date: Thu, 2 Feb 2023 20:37:58 +0100 Subject: [PATCH] add bearer helper function --- src/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 72b094a..5cc0764 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,6 +48,7 @@ export type RouterRequest = { body: string | any raw: Request cf?: IncomingRequestCfProperties + bearer: () => string } & TExt /** @@ -387,7 +388,8 @@ export class Router { raw: request, params: {}, query: {}, - body: '' + body: '', + bearer: () => request.headers.get('Authorization')?.replace('Bearer ', '').trim() ?? '', } as RouterRequest const route = this.getRoute(req)