Giriş
Şu satırı dahil ederiz
import org.springframework.web.reactive.function.server.ServerResponse;
İçine bir Mono nesnesi konulabilir.
Örnek
Şöyle yaparız
import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.ServerResponse; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RouterFunctions.route; @Configuration public class SampleRouter { @Bean public RouterFunction<ServerResponse> sampleRoute(SampleHandler handler) { return route(GET("/simple-route"), handler::handleRequest); } } import org.springframework.web.reactive.function.server.ServerRequest; import org.springframework.web.reactive.function.server.ServerResponse; @Component public class SampleHandler { public Mono<ServerResponse> handleRequest(ServerRequest request) { return ServerResponse.ok().body(Mono.just("Sample Route Successful!"), String.class); } }
Hiç yorum yok:
Yorum Gönder