handy-httpd 3.1.0

Extremely lightweight HTTP server for D.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

handy-httpd

An extremely lightweight HTTP server for the D programming language.

For a complete overview, please visit the wiki.

Here's an example of serving static files from a directory:

import handy_httpd;
import handy_httpd.handlers.file_resolving_handler;

void main() {
	new HttpServer(new FileResolvingHandler("static")).start();
}

It's also quite simple to define your own custom request handler. Here's an example of a custom request handler that only responds to the /hello endpoint:

import handy_httpd;
import handy_httpd.responses;

void main() {
	auto s = new HttpServer(simpleHandler((ref request, ref response) {
		if (request.url == "/hello") {
			response.writeBody("Hello world!");
		} else {
			response.notFound();
		}
	}));
	s.start();
}
Authors:
  • Andrew Lalis <andrewlalisofficial@gmail.com>
Dependencies:
httparsed
Versions:
8.4.2 2024-Sep-27
8.4.1 2024-Aug-02
8.4.0 2024-Apr-16
8.3.2 2024-Feb-16
8.3.1 2024-Feb-14
Show all 73 versions
Download Stats:
  • 3 downloads today

  • 33 downloads this week

  • 84 downloads this month

  • 19594 downloads total

Score:
3.5
Short URL:
handy-httpd.dub.pm