-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http: allow passing server object, for future node http2 #1063
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1063 +/- ##
=========================================
- Coverage 99.72% 98.93% -0.8%
=========================================
Files 5 5
Lines 369 374 +5
=========================================
+ Hits 368 370 +2
- Misses 1 4 +3
Continue to review full report at Codecov.
|
Would it be better with: const Koa = require('koa')
const app = new Koa({ server: 'http2' }) this.server = require(args.server == 'http2' ? 'http2' : 'http'); Otherwise if people pass wrong server value to constructor,they will get error like "this.server.createServer is not a function" and feel confused. |
I don't think this is necessary. We can simply use http2 in the following way.
|
@iyuq I agree with you, but that sort of opens the can for me :) In that case Koa should be completely agnostic and even remove the |
I think
|
0d1edad
to
e244414
Compare
@dead-horse is the update better? This would allow either I'll add tests and docs if this approach is acceptable. |
LGTM |
i'd rather keep |
Closing because of bloat. Update: Clarification If you want to use node.js core http2 module, feed it using require('http2').createSecureServer(cert, new Koa().callback()).listen() |
@fl0w What is the finally solution? |
@Rukeith I believe this was closed in favor of using |
But... what if you want to use both http2 and http1? You need to create 2 separate instances of Koa? |
@felixsanz yes - that would be the case regardless of this PR |
Just trying to get this ball rolling because there's some activity in closed issue #477.
This is what I'm purposing to allow user space to experiment with http2 without breaking backwards compatibility.
Purposed API would become:
I could move the require into the construction if args.server is falsey to avoid loading the library at all if http2 is chosen - not sure about the implications of doing so. I'd still have to be done during initialisation of a Koa application so my two cents would be to do it. Not sure how Koa team feels about a require in a constructor thought :)
PS I am embarrassingly ignorant about http2, and the node implementation.