Middleware

Every request passes through a stack of middleware on its way to your route, and every response passes back through it (Request to Response). Sessions, CSRF checks, CORS, maintenance mode, rate limiting and authentication are all middleware. The examples add a timing header, an API-key check, a locale switch and a post-response hook to the bookshop, each proved with curl 3,008 against php artisan serve --port=8304.

Subsections