Skip to content
Myr

Added `res.links(obj)`

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by TJ Holowaychuk · committed by TJ Holowaychuk · parent d2baf11 · Browse files · 2 files+40 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+40 added−0 removed

  • tests:+19 added−0 removed
  • other:+21 added−0 removed

2 files+40 added−0 removed

modified:lib/response.js+21 added
39 unmodified lines
40 return this;41};4243/**44 * Set Link header field with the given `links`.45 *46 * Examples:47 *48 * res.links({49 * next: 'http://api.example.com/users?page=2',50 * last: 'http://api.example.com/users?page=5'51 * });52 *53 * @param {Object} links54 * @return {ServerResponse}55 * @api public56 */5758res.links = function(links){59 return this.set('Link', Object.keys(links).map(function(rel){60 return '<' + links[rel] + '>; rel="' + rel + '"';61 }).join(', '));62};6364/**65 * Send a response.66 *67 * Examples:68 *
607 unmodified lines
added:test/res.links.js+19 added