Skip to content

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

Class: SetResponseHeaderLayer

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

A layer that sets a specific HTTP response header.

Example

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

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

Implements

Methods

layer()

layer(inner): HttpService

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

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): SetResponseHeaderLayer

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

Creates a new SetResponseHeaderLayer.

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<HttpResponse>

Returns

SetResponseHeaderLayer


ifNotPresent()

static ifNotPresent(name, make): SetResponseHeaderLayer

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

Creates a new SetResponseHeaderLayer.

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

Parameters

name

string

make

MakeHeaderValue<HttpResponse>

Returns

SetResponseHeaderLayer


overriding()

static overriding(name, make): SetResponseHeaderLayer

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

Creates a new SetResponseHeaderLayer.

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

Parameters

name

string

make

MakeHeaderValue<HttpResponse>

Returns

SetResponseHeaderLayer