Function listenHttp
Starts a HTTP server listening on the specified port.
request_handler
will be called for each HTTP request that is made. The res parameter of the callback then has to be filled with the response data.
request_handler
can be either HttpServerRequestDelegate
/HttpServerRequestFunction
or a class/struct with a member function 'handleRequest' that has the same signature.
Note that if the application has been started with the --disthost command line switch, listenHttp
() will automatically listen on the specified VibeDist host instead of locally. This allows for a seamless switch from single-host to multi-host scenarios without changing the code. If you need to listen locally, use listenHttpPlain
() instead.
Prototypes
void listenHttp( HttpServerSettings settings, void delegate(HttpServerRequest req, HttpServerResponse res) request_handler ); void listenHttp( HttpServerSettings settings, void function(HttpServerRequest req, HttpServerResponse res) request_handler ); void listenHttp( HttpServerSettings settings, IHttpServerRequestHandler request_handler );
Parameters
Name | Description |
---|---|
settings | Customizes the HTTP servers functionality. |
request_handler | This callback is invoked for each incoming request and is responsible for generating the response. |
Authors
Sönke Ludwig, Jan Krüger
Copyright
© 2012 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.