1611 shaares
17 private links
17 private links
3 results
tagged
middleware
This middleware ensures that a user is logged in. If a request is received that is unauthenticated, the request will be redirected to a login page. The URL will be saved in the session, so the user can be conveniently returned to the page that was originally requested.
Middleware is a function that receives the request and response objects of an HTTP request/response cycle. It may modify (transform) these objects before passing them to the next middleware function in the chain. It may decide to write to the response; it may also end the response without continuing the chain.
In other frameworks “middleware” is called “filters”, but the concept is the same: a request, response, and some transformation functions.