res.links()

res.links(links) Joins the links provided as properties of the parameter to populate the response’s Link HTTP header field. For example, the following call: res.links({ next: 'http://api.example.com/users?page=2', last: 'http://api.example.com/users?page=5' }); Yields the following results: Link: <http://api.example.com/users?page=2>; rel="next", <http://api.example.com/users?page=5>; rel="last"

res.locals

res.locals An object that contains response local variables scoped to the request, and therefore available only to the view(s) rendered during that request / response cycle (if any). Otherwise, this property is identical to app.locals. This property is useful for exposing request-level information such as the request path name, authenticated user, user settings, and so on. app.use(function(req, res, next){ res.locals.user = req.user; res.locals.authenticated = ! req.user.anonymous; next()

res.location()

res.location(path) Sets the response Location HTTP header to the specified path parameter. res.location('/foo/bar'); res.location('http://example.com'); res.location('back'); A path value of “back” has a special meaning, it refers to the URL specified in the Referer header of the request. If the Referer header was not specified, it refers to “/”. Express passes the specified URL string as-is to the browser in the Location header, without any validation or manipulation, except in case of back.

res.get()

res.get(field) Returns the HTTP response header specified by field. The match is case-insensitive. res.get('Content-Type'); // => "text/plain"

res.jsonp()

res.jsonp([body]) Sends a JSON response with JSONP support. This method is identical to res.json(), except that it opts-in to JSONP callback support. res.jsonp(null); // => null res.jsonp({ user: 'tobi' }); // => { "user": "tobi" } res.status(500).jsonp({ error: 'message' }); // => { "error": "message" } By default, the JSONP callback name is simply callback. Override this with the jsonp callback name setting. The following are some examples of JSONP responses using the same code: /

res.json()

res.json([body]) Sends a JSON response. This method is identical to res.send() with an object or array as the parameter. However, you can use it to convert other values to JSON, such as null, and undefined (although these are technically not valid JSON). res.json(null); res.json({ user: 'tobi' }); res.status(500).json({ error: 'message' });

res.headersSent

res.headersSent Boolean property that indicates if the app sent HTTP headers for the response. app.get('/', function (req, res) { console.log(res.headersSent); // false res.send('OK'); console.log(res.headersSent); // true });

res.end()

res.end([data] [, encoding]) Ends the response process. This method actually comes from Node core, specifically the response.end() method of http.ServerResponse. Use to quickly end the response without any data. If you need to respond with data, instead use methods such as res.send() and res.json(). res.end(); res.status(404).end();

res.format()

res.format(object) Performs content-negotiation on the Accept HTTP header on the request object, when present. It uses req.accepts() to select a handler for the request, based on the acceptable types ordered by their quality values. If the header is not specified, the first callback is invoked. When no match is found, the server responds with 406 “Not Acceptable”, or invokes the default callback. The Content-Type response header is set when a callback is selected. However, you may alter this wi

res.cookie()

res.cookie(name, value [, options]) Sets cookie name to value. The value parameter may be a string or object converted to JSON. The options parameter is an object that can have the following properties. Property Type Description domain String Domain name for the cookie. Defaults to the domain name of the app. encode Function A synchronous function used for cookie value encoding. Defaults to encodeURIComponent. expires Date Expiry date of the cookie in GMT. If not specified or set to 0, creates