This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Long itemId = 42L; | |
BigDecimal vatRate = BigDecimal.of(0.42); | |
// error handling is omitted for brevity | |
return fetchItem(itemId) | |
.flatmap(item -> calculateTax(item, vatRate)) | |
.flatmap(BusinessClass::writeTaxToDB); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AppRouter.java | |
@Configuration | |
public class AppRouter { | |
// works for a single bean | |
@Bean | |
public RouterFunction<ServerResponse> routes(ResouceHandler resourceHandler) { | |
return RouterFunctions.route(GET("/resource/{id}").and(accept(APPLICATION_JSON)), resourceHandler::get) | |
.andRoute(GET("/resource/filter/{filterQuery}").and(accept(APPLICATION_JSON)), resourceHandler::getFiltered); | |
} | |
} |