Thread overview
🚀 Announcing Serverino 0.6.0! 🎉
Mar 10
aberba
March 07

Performance has been boosted once again, and those pesky little bugs? Squashed! Plus, there are fresh examples to try out and even a sleek new logo to admire!

Ready to dive in? Just spin up a new project using the provided template:

dub init -t serverino my_wonderful_project
cd my_wonderful_project
dub

And voilà! Your hello world will be up and running in a couple of seconds! 🌐

Have fun!
Andrea Fontana

(I know some of you are already on board, but how many are sailing in secret? Come out of the shadows and let me know! Your feedback is the wind in serverino's sails)

Repository: https://github.com/trikko/serverino
Docs: https://trikko.github.io/serverino
Examples: https://github.com/trikko/serverino/tree/master/examples
Tips: https://github.com/trikko/serverino/wiki/

March 10

On Thursday, 7 March 2024 at 21:00:03 UTC, Andrea Fontana wrote:

>

Performance has been boosted once again, and those pesky little bugs? Squashed! Plus, there are fresh examples to try out and even a sleek new logo to admire!

Ready to dive in? Just spin up a new project using the provided template:

dub init -t serverino my_wonderful_project
cd my_wonderful_project
dub

And voilà! Your hello world will be up and running in a couple of seconds! 🌐

Have fun!
Andrea Fontana

(I know some of you are already on board, but how many are sailing in secret? Come out of the shadows and let me know! Your feedback is the wind in serverino's sails)

Repository: https://github.com/trikko/serverino
Docs: https://trikko.github.io/serverino
Examples: https://github.com/trikko/serverino/tree/master/examples
Tips: https://github.com/trikko/serverino/wiki/

I'm a heavy user of big express (js) library and I like what I'm seeing. Looks simple and clean. Here are some suggestions:

1) I'm not sure I like concat (~=)
 style used on `Output output` and how it can determine the order routes are invoked. I would expect that to be explicitly defined by Dev using a catch-all route or else the sever returns 404 by default. That's going to prevent the chances of invoking the wrong route especially when it does something important/dangerous/unexpected.
  1. instead of doing:

    if (request.method != Request.Method.Get)
    		output.status = 405;
    

to determine the request method, why not use a UDA similar to @route ...like @method(Request.Method.post)? The use of UDA is so much cleaner and easier to deal with.

  1. would be nice to have an output.json() function which both sets the response header and also calls output.write()
  1. I can't build anything significant in any http server library without support for middleware. Preferably support for multiple middlewares functions. A middleware would be a function that runs after the @onServerInit but BEFORE any route handler. It will be used to intercept all incoming requests for things like authentication, rate limiting, CORS, etc. Preferably provide a way to pass data to the target route e.g. user session, user permission, etc...like output.locals.set("userId", 123). The route will then be able to access this data.

All in all, everything else looks good. I would prefer something like:

```d
void hello (Request req, Response res) {
    res.write("hello");
}
```
...but `Output` is also fine... just a small nitpick.
March 10

Thank you! Inline replies >>>

On Sunday, 10 March 2024 at 21:04:05 UTC, aberba wrote:

>
1) I'm not sure I like concat (~=)
 style used on `Output output` and how it can determine the order routes are invoked. I would expect that to be explicitly defined by Dev using a catch-all route or else the sever returns 404 by default. That's going to prevent the chances of invoking the wrong route especially when it does something important/dangerous/unexpected.

Serverino works with priorities, that's the order the handlers are called! You're checks on handlers can easily filter request.

>
  1. instead of doing:

    if (request.method != Request.Method.Get)
    		output.status = 405;
    

to determine the request method, why not use a UDA similar to @route ...like @method(Request.Method.post)? The use of UDA is so much cleaner and easier to deal with.

This works as well, indeed:
@route!(r => r.method == Request.Method.Post)

>
  1. would be nice to have an output.json() function which both sets the response header and also calls output.write()

Just add content type and you're done!

>
  1. I can't build anything significant in any http server library without support for middleware. Preferably support for multiple middlewares functions. A middleware would be a function that runs after the @onServerInit but BEFORE any route handler. It will be used to intercept all incoming requests for things like authentication, rate limiting, CORS, etc. Preferably provide a way to pass data to the target route e.g. user session, user permission, etc...like output.locals.set("userId", 123). The route will then be able to access this data.

Just use a high priority handler, check the tips on website, for example user auth.

That's a very clean way to add a layer of Auth, logging and so on...

>

All in all, everything else looks good. I would prefer something like:

```d
void hello (Request req, Response res) {
    res.write("hello");
}
```
...but `Output` is also fine... just a small nitpick.

output.write() works as well.

Andrea