handy-httpd 5.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.
Check out the full documentation here.
Features
- HTTP/1.1
- Worker pool for request handling
- Simple configuration
- High performance (low GC usage)
- Beginner friendly
- Extensible with custom handlers, exception handlers, and filters
- Well-documented
- Ships with some handy pre-made request handlers:
- Serve static files with the
FileResolvingHandler
- Apply filters before and after handling requests with the
FilteredHandler
- Handle complex URL paths, including path parameters and wildcards, with the
PathDelegatingHandler
- Serve static files with the
Simple Example
In this example, we take advantage of the Dub package manager's single-file SDL syntax to declare HandyHttpd as a dependency. For this example, we'll call this my_server.d
.
#!/usr/bin/env dub
/+ dub.sdl:
dependency "handy_httpd" version="~>5.0"
+/
import handy_httpd;
void main() {
new HttpServer((ref ctx) {
if (ctx.request.url == "/hello") {
response.writeBody("Hello world!");
} else {
response.notFound();
}
}).start();
}
To start the server, just mark the script as executable, and run it:
chmod +x my_server.d
./my_server.d
And finally, if you navigate to http://localhost:8080/hello, you should see the Hello world!
text appear.
- 5.1.0 released a year ago
- andrewlalis/handy-httpd
- MIT
- Copyright © 2022, Andrew Lalis
- Authors:
- 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 - Download Stats:
-
-
0 downloads today
-
12 downloads this week
-
83 downloads this month
-
19594 downloads total
-
- Score:
- 3.6
- Short URL:
- handy-httpd.dub.pm