WebFlux application server add server.forward- Headers - Strategy = Framework RouterFunction endpoint 404
See original GitHub issueThere are two services:
account-service
, gateway-server
After the account-service
has set the ‘server.forward- Headers - Strategy = Framework’ property.routerFunction endpoint start 404
The following interfaces are accessed through the Spring Cloud Gateway
http://localhost:8080/account/hi
is 404. The generated by RouterFunction endpoint
http://localhost:8080/account/hello
return 200 normal, through RequestMapping annotations
Reproducible Example:
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
How to Return 404 with Spring WebFlux - Baeldung
Learn how to return 404 status code in Spring WebFlux. ... With Spring Boot 2 and the new non-blocking server Netty, we don't...
Read more >Web on Reactive Stack - Spring
At the programming-model level, Java 8 enabled Spring WebFlux to offer functional web endpoints alongside annotated controllers.
Read more >Spring Webflux returns 404 ( Not Foud ) - Stack Overflow
The solution: go to application.properties,; remove server.servlet.context-path; and add spring.webflux.base-path.
Read more >Sending HTTP requests with Spring WebClient - Reflectoring
Let's start simple, with a plain GET request to read some content from a server or API. To get started, you'll first need...
Read more >springdoc-openapi v2.0.0
For the integration between spring-boot and swagger-ui, add the library ... by setting server.forward-headers-strategy is set to FRAMEWORK.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is something that needs to be straightened out in WebFlux.fn. I will pick it up for 5.3, since it will be a breaking change for some people.
Now that #25279 is solved, I’ve checked again with the sample application.
There is a major mapping difference between Spring WebFlux annotations and RouterFunctions mapping:
org.springframework.http.server.RequestPath#pathWithinApplication
org.springframework.web.reactive.function.server.ServerRequest#pathContainer
is returning aPathContainer
, and notRequestPath
(which extendsPathContainer
). The context path is not removed before mapping.Debugging through sample applications show that the
DefaultServerRequest
implementation is using the underlyingRequestPath
, it’s just not exposing it as is.@poutsma @rstoyanchev this difference is the only remaining point here; I can see why RouterFunctions could be considered more explicit, and maybe nesting routes should be used instead here in applications. We’re not calling out that difference anywhere in our documentation as far as I understand, maybe because
contextPath
shouldn’t even be a concept in the functional variant?I managed to reproduce this with a new test in
RequestPredicatesTests
: