Function staticRedirect
Provides a HTTP request handler that responds with a static redirection to the specified URL.
@safe void delegate(HTTPServerRequest, HTTPServerResponse) staticRedirect
(
string url,
HTTPStatus status = cast(HTTPStatus)302
) @safe;
@safe void delegate(HTTPServerRequest, HTTPServerResponse) staticRedirect
(
URL url,
HTTPStatus status = cast(HTTPStatus)302
) @safe;
Parameters
Name | Description |
---|---|
url | The URL to redirect to |
status | Redirection status to use (by default this is HTTPStatus ). |
Returns
Returns a HTTPServerRequestDelegate
that performs the redirect
Example
import vibe .http .router;
void test()
{
auto router = new URLRouter;
router .get("/old_url", staticRedirect("http://example.org/new_url", HTTPStatus .movedPermanently));
listenHTTP(new HTTPServerSettings, router);
}