Closed ericmdantas closed 8 years ago
Go server:
package main
import (
"fmt"
"net/http"
"golang.org/x/net/http2"
)
func main() {
var srv http.Server
http2.VerboseLogs = true
srv.Addr = ":3333"
http2.ConfigureServer(&srv, nil)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("yo!"))
})
log.Fatal(srv.ListenAndServeTLS("crt/server.crt", "crt/server.key"))
}
Node server:
const express = require('express');
const http2 = require('http2');
const app = express();
app.get('/', (req, res) => {
res.end("yo!");
});
var options = {
key: fs.readFileSync('./crt/localhost.key'),
cert: fs.readFileSync('./crt/localhost.crt')
};
http2.createServer(options, app)
.listen(3333, () => {
console.log('server up');
});
Welp, looks like express and the http2 module don't get along yet: https://github.com/molnarg/node-http2/issues/100
Since there's the bug above, node will have to stay with https for now.
As a note, Node servers will have to have its files copied like go's, see here: https://github.com/ericmdantas/generator-ng-fullstack/blob/master/_ng/server/go.js#L39
Done.
Important for node/express: https://github.com/expressjs/express/issues/2761#issuecomment-221675351