spirit icon indicating copy to clipboard operation
spirit copied to clipboard

HTTP 2 support

Open FlorianWendelborn opened this issue 8 years ago • 5 comments

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.

FlorianWendelborn avatar Dec 04 '16 20:12 FlorianWendelborn

I would think this is not spirit related.

Use the http2 module instead of the http module.

Lichtjaeger avatar Dec 05 '16 07:12 Lichtjaeger

@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.

FlorianWendelborn avatar Dec 05 '16 13:12 FlorianWendelborn

~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.

hnry avatar Dec 06 '16 00:12 hnry

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

FlorianWendelborn avatar Dec 07 '16 21:12 FlorianWendelborn

@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.

FlorianWendelborn avatar Jul 17 '17 10:07 FlorianWendelborn