lighttp 0.5.4
Lightweight asynchronous HTTP/WS server
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:
lighttp <img align="right" alt="Logo" width="100" src="https://i.imgur.com/kWWtW6I.png">
Lighttp is a lightweight asynchronous HTTP and WebSocket server library for the D programming language with simple API.
import std.file;
import lighttp;
void main(string[] args) {
Server server = new Server();
server.host("0.0.0.0");
server.host("::");
server.router.add(new Router());
server.router.add(Get("welcome"), new Resource("text/html", read("welcome.html")));
server.run();
}
class Router {
// GET /
@Get("") getIndex(ServerResponse response) {
response.body = "Welcome to lighttp!";
}
// GET /image/uhDUnsj => imageId = "uhDUnsj"
@Get("image", "([a-zA-Z0-9]{7})") getImage(ServerResponse response, string imageId) {
if(exists("images/" ~ imageId)) {
response.contentType = MimeTypes.jpeg;
response.body = read("images/" ~ imageId);
} else {
response.status = StatusCodes.notFound;
}
}
}
- Registered by Kripth
- 0.5.4 released 4 years ago
- Kripth/lighttp
- MIT
- Authors:
- Dependencies:
- urld, xbuffer, libasync
- Versions:
-
0.5.4 2020-Jan-09 0.5.3 2019-Oct-10 0.5.2 2019-Sep-14 0.5.1 2019-Sep-08 0.5.0 2019-Jan-04 - Download Stats:
-
-
2 downloads today
-
6 downloads this week
-
36 downloads this month
-
1108 downloads total
-
- Score:
- 2.2
- Short URL:
- lighttp.dub.pm