RequestServer.serveHttpOnce

void serveHttpOnce(alias fun, CustomCgi = Cgi, long maxContentLength = defaultMaxContentLength)()

Serves a single HTTP request on this thread, with an embedded server, then stops. Designed for cases like embedded oauth responders

History

Added Oct 10, 2020.

Example:

import arsd.cgi;
void main() {
	RequestServer server = RequestServer("127.0.0.1", 6789);
	string oauthCode;
	string oauthScope;
	server.serveHttpOnce!((cgi) {
		oauthCode = cgi.request("code");
		oauthScope = cgi.request("scope");
		cgi.write("Thank you, please return to the application.");
	});
	// use the code and scope given
}