2

I have a WebFlux application that is behind nginx-ingress.

In order to have redirect working (for purposes of Spring Security OAuth) I enabled ForwardedHeaderTransformer.

Now redirects generated by Spring Security OAuth are working fine, but the problem arises when I want to access my API exposed by RouterFunctions.

For instance I have an endpoint GET /someresource. When request is made ForwardedHeaderTransformer adds /api/myservice both to contextPath and uri.

Question is how to expose my api without adding /api/myservice to router function?

Is there any (clean) option to strip contextPath (if it's present) and serve API like this:

fun router() = router {

    "/someresource".nest {

        GET("/", myHandler::getResource)

        GET("/{id}", myHandler::getResources)

Maybe there is a WebFilter that can be triggered just before RouterFunctions or maybe it can be modified in the other way?

I've tried to add HandlerFilterFunction to my router. But it does not work since there is no mapping for /api/myservice registered.

pixel
  • 24,905
  • 36
  • 149
  • 251
  • I've added PR that will cover my use case: https://github.com/spring-projects/spring-framework/pull/22785 – pixel Jun 17 '19 at 09:10

0 Answers0