Skip to content

Repository files navigation

Archttp

A highly performant web framework written in D.

Documents

  1. Quick Start
  2. 快速开始

Example for web server

import archttp;
voidmain()
{
auto app = new Archttp;
app.get("/", (request, response) {
response.send("Hello, World!");
});
app.get("/user/{id:\\d+}", (request, response) {
response.send("User id: "~ request.params["id"]);
});
app.get("/blog/{name}", (request, response) {
response.send("Username: "~ request.params["name"]);
});
app.post("/upload", (request, response) {
response.send("Using post method!");
});
app.get("/download", (request, response) {
response.sendFile("./attachments/avatar.jpg");
});
app.get("/json", (request, response) {
importstd.json;
response.send( JSONValue( ["message" : "Hello, World!"] ) );
});
app.get("/cookie", (request, response) {
importstd.stdio : writeln;
writeln(request.cookie("token"));
writeln(request.cookies());
response.cookie("username", "myuser");
response.cookie(newCookie("token", "0123456789"));
response.send("Set cookies ..");
});
app.listen(8080);
}

Dependencies

Thanks contributors

  • zoujiaqing
  • Heromyth
  • ikod
  • tchaloupka
  • dhasenan

About

A highly performant web framework written in D.

Topics

Resources

Stars

45 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages