staticRedirect

Provides a HTTP request handler that responds with a static redirection to the specified URL.

  1. HTTPServerRequestDelegate staticRedirect(string url, HTTPStatus status)
  2. HTTPServerRequestDelegate staticRedirect(URL url, HTTPStatus status)
    @safe
    staticRedirect
    (,
    HTTPStatus status = HTTPStatus.found
    )

Parameters

url URL

The URL to redirect to

status HTTPStatus

Redirection status to use (by default this is HTTPStatus.found).

Return Value

Returns a HTTPServerRequestDelegate that performs the redirect

Examples

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);
}

Meta