Skip to content

Commit

Permalink
Merge pull request #164 from lyschoening/feat/http2
Browse files Browse the repository at this point in the history
Use HTTP/2 when the http2 package is installed and 'https' option is enabled
  • Loading branch information
justinmchase committed Feb 28, 2016
2 parents 85e939b + d2d5003 commit 3ebf977
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,8 @@
"gulp-stylus": "^2.1.1",
"mocha": "^2.3.4",
"supertest": "^1.1.0"
},
"optionalDependencies": {
"http2": "^3.3.2"
}
}
6 changes: 5 additions & 1 deletion src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ tiny_lr = require("tiny-lr")
lr = undefined
apps = []

http2 = undefined
try
http2 = require('http2')

class ConnectApp
constructor: (options) ->
@port = options.port || "8080"
Expand Down Expand Up @@ -37,7 +41,7 @@ class ConnectApp
@app.use middleware

if @https
@server = https.createServer
@server = (http2 || https).createServer
key: @https.key || fs.readFileSync __dirname + '/certs/server.key'
cert: @https.cert || fs.readFileSync __dirname + '/certs/server.crt'
ca: @https.ca || fs.readFileSync __dirname + '/certs/ca.crt'
Expand Down

0 comments on commit 3ebf977

Please # to comment.