The router function is responsible for routing incoming requests to the correct handler function. If we compare this to the annotation approach, then it is analogous to the @RequestMapping annotation.
A request is matched using RequestPredicate, which tries to validate the intended matching criteria. Our previously created helloHandler can be configured in the following manner:
RouterFunction<ServerResponse> route = RouterFunctions.route(RequestPredicates.path("/hello"),hellowHandler);
The preceding code is doing the following:
- It registers a predicate for the /hello path
- If a request matches this path, the router invokes helloHandler
If we look at RequestPredicate, this is a functional interface in which we need to ...