vibe.d beta banner
get vibe.d
0.10.1

Asynchronous I/O that doesn’t get in your way, written in D

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

NameDescription
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-2017 RejectedSoftware e.K.

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.