vibe.d beta banner
get vibe.d
0.10.0

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

listenHTTP - multiple declarations

Function listenHTTP

Starts a HTTP server listening on the specified port.

HTTPListener listenHTTP(Settings) (
  Settings _settings,
  HTTPServerRequestDelegate request_handler
) @safe
if (is(Settings == string) || is(Settings == HTTPServerSettings));

HTTPListener listenHTTP(Settings) (
  Settings settings,
  HTTPServerRequestFunction request_handler
) @safe
if (is(Settings == string) || is(Settings == HTTPServerSettings));

HTTPListener listenHTTP(Settings) (
  Settings settings,
  HTTPServerRequestHandler request_handler
) @safe
if (is(Settings == string) || is(Settings == HTTPServerSettings));

HTTPListener listenHTTP(Settings) (
  Settings settings,
  HTTPServerRequestDelegateS request_handler
) @safe
if (is(Settings == string) || is(Settings == HTTPServerSettings));

HTTPListener listenHTTP(Settings) (
  Settings settings,
  HTTPServerRequestFunctionS request_handler
) @safe
if (is(Settings == string) || is(Settings == HTTPServerSettings));

HTTPListener listenHTTP(Settings) (
  Settings settings,
  HTTPServerRequestHandlerS request_handler
) @safe
if (is(Settings == string) || is(Settings == HTTPServerSettings));

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.

Parameters

NameDescription
settings Customizes the HTTP servers functionality (host string or HTTPServerSettings object)
request_handler This callback is invoked for each incoming request and is responsible for generating the response.

Returns

A handle is returned that can be used to stop listening for further HTTP requests with the supplied settings. Another call to listenHTTP can be used afterwards to start listening again.

Function listenHTTP

Scheduled for deprecation - use a @safe callback instead.

HTTPListener listenHTTP(Settings) (
  Settings settings,
  @system void delegate(HTTPServerRequest, HTTPServerResponse) request_handler
) @system
if (is(Settings == string) || is(Settings == HTTPServerSettings));

HTTPListener listenHTTP(Settings) (
  Settings settings,
  @system void function(HTTPServerRequest, HTTPServerResponse) request_handler
) @system
if (is(Settings == string) || is(Settings == HTTPServerSettings));

HTTPListener listenHTTP(Settings) (
  Settings settings,
  @system void delegate(scope HTTPServerRequest, scope HTTPServerResponse) request_handler
) @system
if (is(Settings == string) || is(Settings == HTTPServerSettings));

HTTPListener listenHTTP(Settings) (
  Settings settings,
  @system void function(scope HTTPServerRequest, scope HTTPServerResponse) request_handler
) @system
if (is(Settings == string) || is(Settings == HTTPServerSettings));
Authors

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

Copyright

© 2012-2017 Sönke Ludwig

License

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