Archttp 0.1.0 releases updates like ExpressJS so simple!

zoujiaqing zoujiaqing at gmail.com
Tue May 17 14:20:47 UTC 2022


Archttp is a lightweight framework written by DLang. Its 
performance is comparable to Fasthttp, but its syntax is clear 
and clear. This adjustment also prefers ExpressJS with 
lightweight design, which is very elegant and can express the 
development experience with excellent expression.

### Overall API simplification

Now the callback method returns request and response directly 
instead of context, making it easier to use. Bind () and Run () 
are merged into Listen () during startup, saving developers a 
line of code.

```D

import archttp;

void main()
{
     auto app = new Archttp;

     app.Get("/", (request, response) {
         response.send("Hello, World!");
     });

     app.Listen(8080);
}
```

### Cookie writing support

```D

import archttp;

void main()
{
     auto app = new Archttp;

     app.Get("/cookie", (request, response) {
         response.cookie("username", "myuser");
         response.cookie(new Cookie("token", "0123456789"));
         response.send("Set cookies ..");
     });

     app.Listen(8080);
}

```

### The sendFile () method is supported to download files

```D

import archttp;

void main()
{
     auto app = new Archttp;

     app.Get("/download", (request, response) {
         response.sendFile("./attachments/avatar.jpg");
     });

     app.Listen(8080);
}
```

### Then..

It is also compatible with the Windows platform test. As the 
author's development machine system is macOS, there is only one 
Debian VIRTUAL machine for Linux compatibility test. We also hope 
that you can experience the test, and feedback on bugs to the 
author is very welcome!

D is an excellent language with a syntax similar to TypeScript 
scripting languages and performance comparable to Rust and 
Golang. I wish I could develop an ExpressJS framework as simple 
as Golang's!


More information about the Digitalmars-d-announce mailing list