Card 06/ 06

RecapDifficulty: Advanced1 min

Recap: Mapping Requests

Verbs and paths, the three places request data lives, and the response that matches the outcome.

Mapping requests comes down to the four ideas below, each listed with the card that covers it.

What the topic established, and which card it was on
The ideaWhere
Each mapping annotation names a verb and a pathRequest Mapping Annotations: One per HTTP Verb
@PathVariable, @RequestParam and @RequestBody read the path, the query string and the bodyRequest Mapping Example: Reading the Path, the Query String and the Body
Choose the ResponseEntity method by the outcome: created() also sets LocationResponseEntity Example: Choosing the Response That Matches the Outcome
@RestController returns a body; @Controller returns a view name@RestController vs @Controller: When a Returned String Becomes a 404

Read together, a controller's annotations and return types are the API's contract: what each request looks like and what each outcome sends back.