Card 01/ 06

ConceptDifficulty: Intermediate1 min

One Annotation per HTTP Verb

A REST controller method needs Spring to know two things about the request it should answer: which HTTP verb, and which path. @GetMapping("/rides/{id}") says both in one line.

The mapping annotations
AnnotationVerb
@GetMappingGET — read, no side effect
@PostMappingPOST — create
@PutMappingPUT — replace
@DeleteMappingDELETE — remove

All four are specialisations of the more general @RequestMapping, which takes the verb as an argument instead of baking it into the annotation's name — the specific ones exist so the verb is visible at a glance, without reading into the parentheses.