New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Route processing refactor #8463
Conversation
jackson-xml pr to fix up content processor: micronaut-projects/micronaut-jackson-xml#235 |
servlet pr to fix up RouteExecutor dependency: micronaut-projects/micronaut-servlet#363 |
This PR is now ready. The request routing code is now concentrated in RequestLifecycle. This should make it much easier to implement additional filtering behavior, such as reading the request body. |
...r-netty/src/main/java/io/micronaut/http/server/netty/multipart/NettyStreamingFileUpload.java
Outdated
Show resolved
Hide resolved
...r-netty/src/main/java/io/micronaut/http/server/netty/multipart/NettyCompletedFileUpload.java
Outdated
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/MicronautHttpData.java
Outdated
Show resolved
Hide resolved
...etty/src/main/java/io/micronaut/http/server/netty/AbstractBufferingHttpContentProcessor.java
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/BaseRouteCompleter.java
Show resolved
Hide resolved
...ty/src/main/java/io/micronaut/http/server/netty/HttpContentProcessorAsReactiveProcessor.java
Outdated
Show resolved
Hide resolved
...y/src/main/java/io/micronaut/http/server/netty/HttpContentProcessorAsReactiveSubscriber.java
Outdated
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/MicronautHttpData.java
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/MicronautHttpData.java
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/multipart/NettyPartData.java
Outdated
Show resolved
Hide resolved
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.
In the AWS module, I've replaced most of the custom request processing code with the existing code in RouteExecutor. They are mostly the same, but there are a few differences. The biggest change is about uses of I've adjusted a few of these use sites related to route selection to use |
http-server-netty/src/main/java/io/micronaut/http/server/netty/FormRouteCompleter.java
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/FormRouteCompleter.java
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/HttpContentProcessor.java
Show resolved
Hide resolved
...ty/src/main/java/io/micronaut/http/server/netty/HttpContentProcessorAsReactiveProcessor.java
Outdated
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/NettyHttpRequest.java
Outdated
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/NettyRequestLifecycle.java
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/NettyRequestLifecycle.java
Show resolved
Hide resolved
...etty/src/main/java/io/micronaut/http/server/netty/multipart/MultipartBodyArgumentBinder.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/micronaut/http/server/netty/websocket/NettyServerWebSocketUpgradeHandler.java
Show resolved
Hide resolved
http-server-netty/src/main/java/io/micronaut/http/server/netty/RoutingInBoundHandler.java
Show resolved
Hide resolved
I think we need to have more changes done if we want to support reading the request body in the pre-route filters. Probably introducing some internal structure that can represent the request body in different stages (fetched, reactive fetching) and different body contents (JSON, Form etc). That would likely eliminate |
@dstepanov yes more changes are needed. but i think they can be limited to RequestLifecycle and NettyRequestLifecycle now. All previous users of RouteExecutor (netty, netty websocket, jetty, aws) now use RL, and e.g. filter processing is encapsulated (no more calls to filterPublisher), so it should be possible to limit changes to RL. However this PR is too big already. It will be in follow-up PRs. |
Going to approve it as nothing is blocking it. I feel like classes like |
im still testing some changes for your other comments, so please don't merge yet :) |
@graemerocher just finished it, all comments from @dstepanov addressed |
Kudos, SonarCloud Quality Gate passed! |
This is a refactor of route execution, excluding filters (those will follow in #8422). The goals are:
This initial patch factors most of the routing code out of
RoutingInboundHandler
(the response writing code remains), and moves away from reactive for HttpContentProcessor and the route parameter fulfillment code (now called BaseRouteCompleter and FormRouteCompleter).The goal of this PR is to get to a point where I am confident that it will be easy to delay filter execution until the body is available. Ideally the full request lifecycle, from before route resolution, through filter execution, to route execution, will be contained in the RouteRunner class.
edit, For reviewers: Much of the RouteExecutor code was moved to RequestLifecycle. Much of the RoutingInboundHandler code was moved to NettyRequestLifecycle and the two completer classes. Additionally, there is a new MicronautHttpData class that replaces netty's HttpData implementation, and HttpContentProcessor was refactored to not be reactive, which helps avoid concurrency considerations.