How to redirect a request in spring webflux?

后端 未结 3 949
栀梦
栀梦 2021-01-19 02:20

how can I create a redirect rest web service in spring WebFlux? It seems that there is no redirect functionality in WebFlux yet!

I want something like this:

3条回答
  •  忘掉有多难
    2021-01-19 02:47

    @Bean
    RouterFunction routerFunction() {
         route(GET("/redirect"), { req ->
              ServerResponse.temporaryRedirect(URI.create(TargetUrl))
                        .build()
            }
        })
    
    }
    

    Thanks you very much Johan Magnusson

提交回复
热议问题