MCPcopy Create free account
hub / github.com/Effect-TS/effect / redirect

Function redirect

packages/effect/src/unstable/http/HttpServerResponse.ts:143–156  ·  view source on GitHub ↗
(
  location: string | URL,
  options?: Options.WithContent | undefined
)

Source from the content-addressed store, hash-verified

141 * @since 4.0.0
142 */
143export const redirect = (
144 location: string | URL,
145 options?: Options.WithContent | undefined
146): HttpServerResponse => {
147 const headers = Headers.fromRecordUnsafe({ location: location.toString() })
148 return makeResponse({
149 status: options?.status ?? 302,
150 statusText: options?.statusText,
151 headers: options?.headers
152 ? Headers.merge(headers, Headers.fromInput(options.headers))
153 : headers,
154 cookies: options?.cookies ?? Cookies.empty
155 })
156}
157
158/**
159 * Creates an HTTP response whose body is a `Uint8Array`.

Callers

nothing calls this directly

Calls 3

mergeMethod · 0.80
makeResponseFunction · 0.70
toStringMethod · 0.65

Tested by

no test coverage detected