Projects in Node.js: goo.gl/rT7o2k
In this video we'll go more into detail what Middleware means and provide some examples.
We can define middleware as any number of functions that are invoked by the Express.js routing layer before your final request handler is made.
So essentially we're saying, on our defined route Do Something first, then pass it along to the next function. Each time we will use the request/response objects of an HTTP cycle to Alter, End or pass to Next whatever it is we're handling.
In this example before sending someone to the route they request we would deal any CORS or CSRF issues that may arise, we'd check to see if the user was authorized and if all is good, then we would send them to where they want to go.
コメント