The response redirects (3xx, or exactly status when given) to location.
- location: the
Locationthe response must have. - status: the exact status wanted. 0 accepts any 3xx.
go_home :: () -> Response {
return redirect("/home");
}
main :: () {
app: App;
defer free_app(*app);
get(*app, "/", go_home);
api := test_client(*app);
response, _ := get(api, "/");
defer close(*response);
assert(expect_redirect(response, "/home", 302));
}Doesn't run in the browser (skipped on wasm).
expect_redirect :: (
response: Client_Response,
location: string,
status := 0,
loc := #caller_location
) -> bool
The response redirects (3xx, or exactly status when given) to location.
Parameters
- response: Client_Response
- location: string
- the
Locationthe response must have. - status := 0
- the exact status wanted. 0 accepts any 3xx.
- loc := #caller_location
Returns
- bool
go_home :: () -> Response {
return redirect("/home");
}
main :: () {
app: App;
defer free_app(*app);
get(*app, "/", go_home);
api := test_client(*app);
response, _ := get(api, "/");
defer close(*response);
assert(expect_redirect(response, "/home", 302));
}Doesn't run in the browser (skipped on wasm).