Http module

redirect

procedureextensionexperimentalSource

A redirect to location: 302 unless you pass 301, 303, 307 or 308.

Example
response := redirect("/login", 303);
location, _ := find_header(response.headers, "Location");
assert(response.status == 303 && location == "/login");

Doesn't run in the browser (skipped on wasm).

redirect :: (location: string, status := 302) -> Response

A redirect to location: 302 unless you pass 301, 303, 307 or 308.

Parameters

location: string
the URL to go to, as an absolute URL or a path.
status := 302
301, 302, 303, 307 or 308. Use 303 after a POST, 307 or 308 to keep the method.

Returns

Example
response := redirect("/login", 303);
location, _ := find_header(response.headers, "Location");
assert(response.status == 303 && location == "/login");

Doesn't run in the browser (skipped on wasm).

See also