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 = HTTPStatus .found
) @safe;
@safe void delegate(HTTPServerRequest, HTTPServerResponse) staticRedirect
(
URL url,
HTTPStatus status = HTTPStatus .found
) @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);
}