router.all()

router.all(path, [callback, ...] callback) This method is just like the router.METHOD() methods, except that it matches all HTTP methods (verbs). This method is extremely useful for mapping “global” logic for specific path prefixes or arbitrary matches. For example, if you placed the following route at the top of all other route definitions, it would require that all routes from that point on would require authentication, and automatically load a user. Keep in mind that these callbacks do not h

res.vary()

res.vary(field) Adds the field to the Vary response header, if it is not there already. res.vary('User-Agent').render('docs');

res.type()

res.type(type) Sets the Content-Type HTTP header to the MIME type as determined by mime.lookup() for the specified type. If type contains the “/” character, then it sets the Content-Type to type. res.type('.html'); // => 'text/html' res.type('html'); // => 'text/html' res.type('json'); // => 'application/json' res.type('application/json'); // => 'application/json' res.type('png'); // => image/png:

res.status()

res.status(code) Sets the HTTP status for the response. It is a chainable alias of Node’s response.statusCode. res.status(403).end(); res.status(400).send('Bad Request'); res.status(404).sendFile('/absolute/path/to/404.png');

res.set()

res.set(field [, value]) Sets the response’s HTTP header field to value. To set multiple fields at once, pass an object as the parameter. res.set('Content-Type', 'text/plain'); res.set({ 'Content-Type': 'text/plain', 'Content-Length': '123', 'ETag': '12345' }); Aliased as res.header(field [, value]).

res.sendStatus()

res.sendStatus(statusCode) Sets the response HTTP status code to statusCode and send its string representation as the response body. res.sendStatus(200); // equivalent to res.status(200).send('OK') res.sendStatus(403); // equivalent to res.status(403).send('Forbidden') res.sendStatus(404); // equivalent to res.status(404).send('Not Found') res.sendStatus(500); // equivalent to res.status(500).send('Internal Server Error') If an unsupported status code is specified, the HTTP status is still set

res.sendFile()

res.sendFile(path [, options] [, fn]) res.sendFile() is supported by Express v4.8.0 onwards Transfers the file at the given path. Sets the Content-Type response HTTP header field based on the filename’s extension. Unless the root option is set in the options object, path must be an absolute path to the file. The following table provides details on the options parameter. Property Description Default Availability maxAge Sets the max-age property of the Cache-Control header in milliseconds or a

res.send()

res.send([body]) Sends the HTTP response. The body parameter can be a Buffer object, a String, an object, or an Array. For example: res.send(new Buffer('whoop')); res.send({ some: 'json' }); res.send('<p>some html</p>'); res.status(404).send('Sorry, we cannot find that!'); res.status(500).send({ error: 'something blew up' }); This method performs many useful tasks for simple non-streaming responses: For example, it automatically assigns the Content-Length HTTP response header field

res.render()

res.render(view [, locals] [, callback]) Renders a view and sends the rendered HTML string to the client. Optional parameters: locals, an object whose properties define local variables for the view. callback, a callback function. If provided, the method returns both the possible error and rendered string, but does not perform an automated response. When an error occurs, the method invokes next(err) internally. The local variable cache enables view caching. Set it to true, to cache the view

res.redirect()

res.redirect([status,] path) Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code . If not specified, status defaults to “302 “Found”. res.redirect('/foo/bar'); res.redirect('http://example.com'); res.redirect(301, 'http://example.com'); res.redirect('../login'); Redirects can be a fully-qualified URL for redirecting to a different site: res.redirect('http://google.com'); Redirects can be relative to the root o