Added gzip compression to HTTP server

pull/69/head
Thomas Buckley-Houston 2018-06-26 13:57:52 +08:00
rodzic 1bbe912994
commit c0c68842f0
3 zmienionych plików z 15 dodań i 2 usunięć

8
interfacer/Gopkg.lock wygenerowano
Wyświetl plik

@ -1,6 +1,12 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
name = "github.com/NYTimes/gziphandler"
packages = ["."]
revision = "2600fb119af974220d3916a5916d6e31176aac1b"
version = "v1.0.1"
[[projects]]
branch = "master"
name = "github.com/gdamore/encoding"
@ -82,6 +88,6 @@
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "d45276f27c8406a168f3f82f609de071ef087fef39e2135d2e2a87b00f15b0bd"
inputs-digest = "9cfbfff2e0d37769847cce1dc7f703a02f24f4aae03b495cf9179d67841ac455"
solver-name = "gps-cdcl"
solver-version = 1

Wyświetl plik

@ -13,3 +13,7 @@
[[constraint]]
branch = "master"
name = "github.com/shibukawa/configdir"
[[constraint]]
name = "github.com/NYTimes/gziphandler"
version = "v1.0.1"

Wyświetl plik

@ -8,6 +8,8 @@ import (
"crypto/rand"
"io"
"time"
"github.com/NYTimes/gziphandler"
)
// In order to communicate between the incoming HTTP request and the websocket request to the
@ -26,7 +28,8 @@ func HTTPServerStart() {
go startWebSocketServer()
Log("Starting Browsh HTTP server")
serverMux := http.NewServeMux()
serverMux.HandleFunc("/", handleHTTPServerRequest)
uncompressed := http.HandlerFunc(handleHTTPServerRequest)
serverMux.Handle("/", gziphandler.GzipHandler(uncompressed))
if err := http.ListenAndServe(":" + *HTTPServerPort, &slashFix{serverMux}); err != nil {
Shutdown(err)
}