Skip to content

Taxum / @taxum/core / middleware/set-header / SetRequestHeaderLayer

Class: SetRequestHeaderLayer

Defined in: middleware/set-header.ts:120

A layer that sets a specific HTTP request header.

Example

ts
import { SetRequestHeaderLayer } from "@taxum/core/middleware/set-header";
import { m, Router } from "@taxum/core/routing";

const router = new Router()
    .route("/", m.get(() => "Hello World))
    .layer(new SetRequestHeaderLayer("Content-Type", "text/plain"));

Implements

Methods

layer()

layer(inner): HttpService

Defined in: middleware/set-header.ts:169

Wrap the given service with the middleware, returning a new service that has been decorated with the middleware.

Parameters

inner

HttpService

Returns

HttpService

Implementation of

Layer.layer


appending()

static appending(name, make): SetRequestHeaderLayer

Defined in: middleware/set-header.ts:150

Creates a new SetRequestHeaderLayer.

The new header is always added, preserving any existing values. If previous values exist, the header will have multiple values.

Parameters

name

string

make

MakeHeaderValue<HttpRequest>

Returns

SetRequestHeaderLayer


ifNotPresent()

static ifNotPresent(name, make): SetRequestHeaderLayer

Defined in: middleware/set-header.ts:162

Creates a new SetRequestHeaderLayer.

If a previous value exists for the header, the new value is not inserted.

Parameters

name

string

make

MakeHeaderValue<HttpRequest>

Returns

SetRequestHeaderLayer


overriding()

static overriding(name, make): SetRequestHeaderLayer

Defined in: middleware/set-header.ts:137

Creates a new SetRequestHeaderLayer.

If a previous value exists for the same header, it is removed and replaced with the new header value.

Parameters

name

string

make

MakeHeaderValue<HttpRequest>

Returns

SetRequestHeaderLayer