简体   繁体   中英

Redirect /logout request to /api/logout webflux spring boot

I am trying to redirect default logout of spring (/logout) to some other endpoint(/api/exit). I am using reactive programming webflux. I got some answer and i found this:

@Bean
RouterFunction<ServerResponse> routerFunction() {
    return  route(GET("/"), req ->
            ServerResponse.temporaryRedirect(URI.create("/login"))
                    .build());
}

I am not getting which class i have to import for GET("/") method. How to resolve this?

You need RequestPredicates.GET() which comes from org.springframework.web.reactive.function.server.RequestPredicates

So, the import statement will look like

import org.springframework.web.reactive.function.server.RequestPredicates;

Alternatively, you can also use the following to create functional endpoints

import org.springframework.web.reactive.function.server.RouterFunctions;

RouterFunctions.route().GET().build()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM