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

Function redirect

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

Source from the content-addressed store, hash-verified

156 * @since 4.0.0
157 */
158export const redirect = (
159 location: string | URL,
160 options?: Options.WithContent | undefined
161): HttpServerResponse => {
162 const headers = Headers.fromRecordUnsafe({ location: location.toString() })
163 return makeResponse({
164 status: options?.status ?? 302,
165 statusText: options?.statusText,
166 headers: options?.headers
167 ? Headers.merge(headers, Headers.fromInput(options.headers))
168 : headers,
169 cookies: options?.cookies ?? Cookies.empty
170 })
171}
172
173/**
174 * Creates an HTTP response whose body is a `Uint8Array`.

Callers

nothing calls this directly

Calls 3

makeResponseFunction · 0.70
toStringMethod · 0.65
mergeMethod · 0.65

Tested by

no test coverage detected