MultipleResponses

Can return one of the given types, decided at runtime. The syntax is to declare all the possible types in the return value, then you can return typeof(return)(...value...) to construct it.

It has an auto-generated constructor for each value it can hold.

MultipleResponses!(Redirection, string) getData(int how) {
	if(how & 1)
		return typeof(return)(Redirection("http://dpldocs.info/"));
	else
		return typeof(return)("hi there!");
}

If you have lots of returns, you could, inside the function, alias r = typeof(return); to shorten it a little.

version(with_breaking_cgi_features)
struct MultipleResponses (
T...
) {}

Members

Functions

visit
void visit(Handlers handlers)

This is primarily for testing. It is your way of getting to the response.

Meta