valum-framework / valum

Web micro-framework written in Vala
https://valum-framework.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
226 stars 23 forks source link

Ideas for VSGI (before it's too late) #165

Closed arteymix closed 8 years ago

arteymix commented 8 years ago

I have two idea that could change quite a lot VSGI design:

The cancellable API would provide the capability to the server to literally cancel a dispatched request processing. http://valadoc.org/#!api=gio-2.0/GLib.Cancellable

In short, if a client connection closes before time, we could cancel the whole process gracefully.

The return value for ApplicationCallback would let the caller know if the request has been or will eventually be handled (asynchronously). For Valum, it is a very interesting change because we could simply return the next callback:

app.get ("", (req, res, next) => {
    if (authenticated (req))
        return next (req, res);
    throw new ClientError.NOT_AUTHORIZED ("");
};

However, these two changes would affect the APIs quite drastically. The cancellable can be implemented in the Request or Response object.

arteymix commented 8 years ago

FastCGI can abort the request: http://www.fastcgi.com/devkit/doc/fcgi-spec.html#S5.4

arteymix commented 8 years ago

I introduced two changes related to VSGI:

arteymix commented 8 years ago

I merged the return value and it's really awesome:

The cancellable API and I/O priority could be part of the context.

arteymix commented 8 years ago

We don't really need a cancellable/priority API since this is something we would rather do specifically.

Returning a boolean value from the callbacks was a very elegant solution for the continuation-passing style.