Function staticRedirect
Provides a HTTP request handler that responds with a static redirection to the specified URL.
Prototypes
void delegate(HTTPServerRequest, HTTPServerResponse) staticRedirect(
string url,
HTTPStatus status = cast(HTTPStatus)302
);
void delegate(HTTPServerRequest, HTTPServerResponse) staticRedirect(
URL url,
HTTPStatus status = cast(HTTPStatus)302
);
Parameters
Name | Description |
---|---|
url | The URL to redirect to |
status | Redirection status to use (by default this is HTTPStatus.found). |
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);
}
Authors
Sönke Ludwig, Jan Krüger, Ilya Shipunov
Copyright
© 2012-2013 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.