A REST endpoint is an addressable HTTP interface that lets a client access backend data or functionality. Unlike a website that typically returns HTML, a REST API usually responds with data such as JSON or XML. The same API can serve different kinds of clients, including mobile and browser-based applications. section 7.0 section 7.1
In Spring MVC, request-mapping annotations connect HTTP requests to controller methods. A Taco Cloud endpoint, for example, can handle a GET request to fetch recently created tacos. Other annotations handle requests commonly used to create, update, or delete resources; those method-to-operation matches are useful conventions, not perfect rules. section 7.1
Table 7.1 Spring MVC’s HTTP request-handling annotations (view table figure)
| Typical usea |
||
|---|---|---|
| General-purpose request handling; HTTP |
||
| a Mapping HTTP methods to create, read, update, and delete (CRUD) operations isn’t a perfect match, but in practice, that’s how they’re often used and how you’ll use them in Taco Cloud. |
||
Use this table to choose a Spring MVC annotation for an HTTP method. @RequestMapping is the general-purpose alternative, with the method specified separately. section 7.1
A functional request handler offers another way to define a mapping. A RouterFunction connects a request predicate—a condition a request must match—to a handler function. The predicate can match both an HTTP method and a path. section 12.2
package hello;
import static org.springframework.web
.reactive.function.server.RequestPredicates.GET;
import static org.springframework.web
.reactive.function.server.RouterFunctions.route;
import static org.springframework.web
.reactive.function.server.ServerResponse.ok;
import static reactor.core.publisher.Mono.just;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
@Configuration
public class RouterFunctionConfig {
@Bean
public RouterFunction<?> helloRouterFunction() {
return route(GET("/hello"),
request -> ok().body(just("Hello World!"), String.class))
;
}
}
This configuration maps GET /hello to a handler. The handler returns HTTP 200 with a Hello World! response body; the value is wrapped in a Mono. Add another mapping with andRoute() when the same router needs to handle another request. section 12.2
Not every Spring route is an HTTP endpoint. An RSocket controller uses @MessageMapping to handle messages on a named route rather than HTTP requests for a path. section 14.2.1


























