Skip to main content
Module

x/hsts_middleware/deps.ts>withHeader

HTTP Strict Transport Security(HSTS) middleware
Latest
function withHeader
import { withHeader } from "https://deno.land/x/hsts_middleware@1.0.1/deps.ts";

Return an instance with the provided Request replacing the specified header. There are no side effects on the original Request.

Examples

Example 1

import { withHeader } from "https://deno.land/x/http_utils@$VERSION/message.ts";
import { assert } from "https://deno.land/std@$VERSION/testing/asserts.ts";

declare const init: Request;
declare const header: string;
declare const value: string;

const request = withHeader(init, header, value);

assert(request.headers.get(header), value);
assert(init !== request);

Parameters

request: Request
fieldName: string
fieldValue: string

Return an instance with the provided Response replacing the specified header. There are no side effects on the original Response.

Examples

Example 1

import { withHeader } from "https://deno.land/x/http_utils@$VERSION/message.ts";
import { assert } from "https://deno.land/std@$VERSION/testing/asserts.ts";

declare const init: Response;
declare const header: string;
declare const value: string;

const response = withHeader(init, header, value);

assert(response.headers.get(header), value);
assert(init !== response);

Parameters

response: Response
fieldName: string
fieldValue: string