Skip to content

Commit

Permalink
Fix findRouteMatch for aws requests
Browse files Browse the repository at this point in the history
micronaut-function-aws-api-proxy requests include the host in getUri. This leads to no match with findAny. This causes the AVAILABLE_HTTP_METHODS to be empty, which causes a test failure with CorsFilter in the aws module.

Unfortunately I can't test this using CorsFilterSpec in this repo, because CorsFilterSpec calls findAny directly instead of using the findRouteMatch code path. There is also a PR for refactoring CorsFilterSpec (#8473) but it does not get rid of the mocking either.
  • Loading branch information
yawkat committed Dec 10, 2022
1 parent d5bafc3 commit 686de0f
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -174,7 +174,7 @@ UriRouteMatch<Object, Object> findRouteMatch(HttpRequest<?> httpRequest) {
}

if (routeMatch == null && httpRequest.getMethod().equals(HttpMethod.OPTIONS)) {
List<UriRouteMatch<Object, Object>> anyUriRoutes = router.findAny(httpRequest.getUri().toString(), httpRequest).toList();
List<UriRouteMatch<Object, Object>> anyUriRoutes = router.findAny(httpRequest.getPath(), httpRequest).toList();
if (!anyUriRoutes.isEmpty()) {
setRouteAttributes(httpRequest, anyUriRoutes.get(0));
httpRequest.setAttribute(AVAILABLE_HTTP_METHODS, anyUriRoutes.stream().map(UriRouteMatch::getHttpMethod).toList());
Expand Down

0 comments on commit 686de0f

Please sign in to comment.