Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. @Configuration
  2. public class BookRouter {
  3.  
  4. @Bean
  5. public RouterFunction<ServerResponse> routeBooks(BookHandler bookHandler) {
  6. return RouterFunctions
  7. .route(RequestPredicates.GET("/books")
  8. .and(RequestPredicates.accept(MediaType.APPLICATION_JSON)), bookHandler::getBooks)
  9. .andRoute(RequestPredicates.GET("/books/{id}")
  10. .and(RequestPredicates.accept(MediaType.APPLICATION_JSON)), bookHandler::getBook);
  11. }
  12. }
  13.  
  14. public class BookHandler {
  15.  
  16. public Mono<ServerResponse> getBook(ServerRequest request) {
  17. return ServerResponse
  18. .ok()
  19. .hint(Jackson2CodecSupport.JSON_VIEW_HINT, MyJacksonView.class)
  20. .body(...)
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement