Skip to main content
Module

x/fathym_common/src/common/http/redirectRequest.ts>redirectRequest

The Fathym Reference Architecture provides the common foundation for applications built in Typescript.
Go to Latest
function redirectRequest
import { redirectRequest } from "https://deno.land/x/fathym_common@v0.2.147-integration/src/common/http/redirectRequest.ts";

Redirects the request to a new location with the specified status code.

Examples

From direct import

import { redirectRequest } from "@fathym/common/http";

const resp = redirectRequest("/new-location", 301);

From common import

import { redirectRequest } from "@fathym/common";

const resp = redirectRequest("/new-location", 301);

Parameters

location: string

The location to redirect to.

status: number

The HTTP status code to use for the redirect.

optional
req: Request

The base request for relative redirect.

optional
respHeaders: Headers

The additional response headers for the redirect.

Returns

The redirected response.

Redirects the request to a new location with flags for permanent and preserve.

Examples

From direct import

import { redirectRequest } from "@fathym/common/http";

const resp = redirectRequest("/new-location", false, true);

From common import

import { redirectRequest } from "@fathym/common";

const resp = redirectRequest("/new-location", false, true);

Parameters

location: string

The location to redirect to.

preserve: boolean

Whether to preserve the original request headers.

permanent: boolean

Whether the redirect should be permanent.

optional
reqResp: Request

The base request for relative redirect.

optional
respHeaders: Headers

The additional response headers for the redirect.

Returns

The redirected response.