spirit-js / spirit

Modern modular library for building web applications
http://spirit.function.run
ISC License
244 stars 18 forks source link

HTTP 2 support #12

Open FlorianWendelborn opened 7 years ago

FlorianWendelborn commented 7 years ago

Is there any HTTP 2 support for spirit? Is it possible to implement this with the current middleware API?

Combining resources would be the most important bit for my use-case, since I'm trying to reduce the initial latency of first loading a .js and then letting that .js load a .css. Due to caching issues it's unfortunately not possible to do both at the same time, except by using HTTP 2.

Lichtjaeger commented 7 years ago

I would think this is not spirit related.

Use the http2 module instead of the http module.

FlorianWendelborn commented 7 years ago

@Lichtjaeger Yes, it might be possible to "hack" a solution that'll work by including ['request'] in every route. However that'd completely remove the main advantages of spirit, namely the easy-to-write unit-tests and the verbose, but precise syntax. Something like return {body, header, push, status} would be a lot nicer.

hnry commented 7 years ago

~Was looking at http2 support very early on but the module was buggy so I left it.~

~So what you proposed @dodekeract was my initial plan. It'll have to go in the node adapter.~

~The middleware space would be used for higher level support if someone wants to do something more automated or specific to their needs.~

UPDATE: Looks like core http2 support is moving along since I last checked, https://github.com/nodejs/http2 Better to just wait for that. I don't believe too many people actually use the http2 npm package in production.

FlorianWendelborn commented 7 years ago

I'm fine with waiting, since we can (for the moment) just use CloudFlare, which supports HTTP2 by setting some custom headers.

FlorianWendelborn commented 6 years ago

@hnry https://medium.com/@jasnell/say-hello-to-http-2-for-node-js-core-261ba493846e

Anything we can do so far? I think being one of the first HTTP2 frameworks could do wonders for popularity of spirit.