vibe.d beta banner
get vibe.d

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

Function listenHTTP

Starts a HTTP server listening on the specified port.

void listenHTTP (
  HTTPServerSettings settings,
  void delegate(HTTPServerRequest, HTTPServerResponse) request_handler

void listenHTTP (
  HTTPServerSettings settings,
  void function(HTTPServerRequest, HTTPServerResponse) request_handler

void listenHTTP (
  HTTPServerSettings settings,
  HTTPServerRequestHandler request_handler

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.


settings Customizes the HTTP servers functionality.
request_handler This callback is invoked for each incoming request and is responsible for generating the response.

Sönke Ludwig, Jan Krüger, Ilya Shipunov


© 2012-2013 RejectedSoftware e.K.


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.