vibe.d beta banner
get vibe.d
0.10.0

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

Function HTTPServerResponse.redirect

Sends a redirect request to the client.

void redirect (
  string url,
  int status = 302
) @safe;

void redirect (
  URL url,
  int status = 302
) @safe;

Parameters

NameDescription
url The URL to redirect to
status The HTTP redirect status (3xx) to send - by default this is HTTPStatus.found

Example

import vibe.http.router;

void request_handler(HTTPServerRequest req, HTTPServerResponse res)
{
	res.redirect("http://example.org/some_other_url");
}

void test()
{
	auto router = new URLRouter;
	router.get("/old_url", &request_handler);

	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.