Manipulate the HTTP Vary header.
Vary is based on vary and has been ported for use on Deno
Use the following import:
import { vary } from "https://raw.githubusercontent.com/dmpjs/vary/master/mod.ts"; // import from github as raw data
import { vary } from "https://deno.land/x/vary/mod.ts"; // If module is uploaded into deno.land
Adds the given header field to the Vary response header of response. This can be a string of a single field, a string of a valid Vary header, or an array of multiple fields.
This will append the header if not already listed, otherwise leaves it listed in the current location.
import { Drash } from "https://deno.land/x/[email protected]/mod.ts";
import { vary } from "https://raw.githubusercontent.com/dmpjs/vary/master/mod.ts";
let response: Drash.response
// Append "Origin" to the Vary header of the response
vary(
(header: string) => response.headers.get(header) || "",
(header: string, value: string) => { response.headers.set(header, value)},
'Origin'
)
Adds the given header field to the Vary response header string header. This can be a string of a single field, a string of a valid Vary header, or an array of multiple fields.
This will append the header if not already listed, otherwise leaves it listed in the current location. The new header string is returned.
import { append } from "https://raw.githubusercontent.com/dmpjs/vary/master/mod.ts";
// Get header string appending "Origin" to "Accept, User-Agent"
append('Accept, User-Agent', 'Origin')
Run
deno test ./test.ts
This library follows semantic versioning, and additions to the code ruleset are performed in major releases.
Please have a look at CHANGELOG.md
.
Please have a look at CONTRIBUTING.md
.
Please have a look at CODE_OF_CONDUCT.md
.
This package is licensed using the MIT License.
Please have a look at LICENSE.md
.