One HTTP request: from socket to @GetMapping
The request has a lifecycle — know it cold
A Spring Boot HTTP request is not magic; it is an ordered sequence of well-named responsibilities. Memorize the order. Everything else in this course — security, validation, data access, testing — plugs into a specific step of this pipeline.
- Tomcat (embedded) accepts the TCP connection and parses the HTTP request.
- Servlet filters run in configured order (security, CORS, request logging, etc.).
DispatcherServletconsultsHandlerMappingto find the controller method.HandlerInterceptors fire (pre-handle).- Arguments are resolved by
HandlerMethodArgumentResolvers (path vars, JSON body, headers). - Your controller method runs. It returns a value or throws.
- The return value is converted to an HTTP body via
HttpMessageConverters. - Interceptors' post-handle and after-completion fire; filters wind back out in reverse order.
@RestController
@RequestMapping("/api/invoices")
class InvoiceController {
private final InvoiceService service;
InvoiceController(InvoiceService service) { this.service = service; }
@GetMapping("/{id}")
InvoiceDto get(@PathVariable long id) {
return service.load(id).toDto();
}
}Takeaways
- Every request walks the same pipeline; know the order.
- Controllers are edges — translate HTTP to domain calls and back.
- Cross-cutting concerns belong in filters/interceptors, not controllers.
Enjoying This Lesson?
Your support helps create more comprehensive courses and lessons like this one. Help me build better learning experiences for everyone.
Support Awashyak