Enable HTTP/2
This commit is contained in:
parent
137cf3224d
commit
d9b63dd0ef
54 changed files with 21568 additions and 3 deletions
|
@ -1,7 +1,6 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -12,6 +11,7 @@ import (
|
|||
|
||||
"github.com/khlieng/dispatch/Godeps/_workspace/src/github.com/gorilla/websocket"
|
||||
"github.com/khlieng/dispatch/Godeps/_workspace/src/github.com/spf13/viper"
|
||||
"github.com/khlieng/dispatch/Godeps/_workspace/src/golang.org/x/net/http2"
|
||||
|
||||
"github.com/khlieng/dispatch/letsencrypt"
|
||||
"github.com/khlieng/dispatch/storage"
|
||||
|
@ -60,6 +60,8 @@ func startHTTP() {
|
|||
Handler: http.HandlerFunc(serve),
|
||||
}
|
||||
|
||||
http2.ConfigureServer(server, nil)
|
||||
|
||||
if certExists() {
|
||||
log.Println("[HTTPS] Listening on port", portHTTPS)
|
||||
server.ListenAndServeTLS(viper.GetString("https.cert"), viper.GetString("https.key"))
|
||||
|
@ -78,7 +80,7 @@ func startHTTP() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
server.TLSConfig = &tls.Config{GetCertificate: letsEncrypt.GetCertificate}
|
||||
server.TLSConfig.GetCertificate = letsEncrypt.GetCertificate
|
||||
|
||||
log.Println("[HTTPS] Listening on port", portHTTPS)
|
||||
log.Fatal(listenAndServeTLS(server))
|
||||
|
|
|
@ -11,7 +11,9 @@ import (
|
|||
)
|
||||
|
||||
func listenAndServeTLS(srv *http.Server) error {
|
||||
srv.TLSConfig.NextProtos = []string{"http/1.1"}
|
||||
if srv.TLSConfig.NextProtos == nil {
|
||||
srv.TLSConfig.NextProtos = []string{"http/1.1"}
|
||||
}
|
||||
|
||||
ln, err := net.Listen("tcp", srv.Addr)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue