Skip to content

Instantly share code, notes, and snippets.

@benedyktdryl
Created March 1, 2017 22:13
Show Gist options
  • Save benedyktdryl/bff689ead4d557f0e119e976d2ce35cc to your computer and use it in GitHub Desktop.
Save benedyktdryl/bff689ead4d557f0e119e976d2ce35cc to your computer and use it in GitHub Desktop.
'use strict'
const fs = require('fs')
const Hapi = require('hapi')
const Http2 = require('http2')
const server = new Hapi.Server()
let listener = Http2.createServer({
key: fs.readFileSync('./key.pem'),
cert: fs.readFileSync('./cert.pem')
})
if (!listener.address) {
listener.address = function() {
return this._server.address()
}
}
server.connection({
listener: listener,
port: '8000',
tls: true
})
server.route({
method: 'GET',
path: '/',
handler: (request, reply) => reply('hello world')
})
server.start(err => {
if (err) console.error(err)
console.log(`Started ${server.connections.length} connections`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment