Skip to content

Taxum / @taxum/core / http / Redirect

Class: Redirect

Defined in: http/common.ts:77

Response that redirects the request to another location.

Example

ts
import { Redirect } from "@taxum/core/http";
import { m, Router } from "@taxum/core/routing";

const router = new Router()
    .route("/old", m.get(() => Redirect.permanent("/new")))
    .route("/new", m.get(() => "Hello!"));

Implements

Methods

[TO_HTTP_RESPONSE]()

[TO_HTTP_RESPONSE](): HttpResponse

Defined in: http/common.ts:125

Returns

HttpResponse

Implementation of

ToHttpResponse.[TO_HTTP_RESPONSE]


permanent()

static permanent(uri): Redirect

Defined in: http/common.ts:121

Create a new Redirect that uses 308 Permanent Redirect status code.

See MDN: 308 Permanent Redirect

Parameters

uri

string | URL

Returns

Redirect


temporary()

static temporary(uri): Redirect

Defined in: http/common.ts:111

Create a new Redirect that uses 307 Temporary Redirect status code.

This has the same behavior as Redirect.to, except it will preserve the original HTTP method and body.

See MDN: 307 Temporary Redirect

Parameters

uri

string | URL

Returns

Redirect


to()

static to(uri): Redirect

Defined in: http/common.ts:98

Create a new Redirect that uses 303 See Other status code.

This redirect instructs the client to change the method to GET for the subsequent request to the given uri, which is useful after successful form submission, file upload or when you generally don't want the redirected-to page to observe the original request method and body (if non-empty). If you want to preserve the request method and body, Redirect.temporary should be used instead.

See MDN: 303 See Other

Parameters

uri

string | URL

Returns

Redirect