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.

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

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()

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

Meta