feat: Store methods in MethodNotAllowedHttpError

This commit is contained in:
Joachim Van Herwegen
2022-03-25 11:34:19 +01:00
parent f3dedf4e27
commit effc20a270
8 changed files with 62 additions and 15 deletions

View File

@@ -47,7 +47,7 @@ export class RouterHandler extends HttpHandler {
throw new BadRequestHttpError('Cannot handle request without a method');
}
if (!this.allMethods && !this.allowedMethods.includes(request.method)) {
throw new MethodNotAllowedHttpError(`${request.method} is not allowed.`);
throw new MethodNotAllowedHttpError([ request.method ], `${request.method} is not allowed.`);
}
const pathName = await getRelativeUrl(this.baseUrl, request, this.targetExtractor);
if (!this.allowedPathNamesRegEx.some((regex): boolean => regex.test(pathName))) {