Skip to content

Commit

Permalink
Added gzip compression to HTTP server
Browse files Browse the repository at this point in the history
  • Loading branch information
tombh committed Jun 26, 2018
1 parent 1bbe912 commit c0c6884
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion interfacer/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions interfacer/Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
[[constraint]]
branch = "master"
name = "github.com/shibukawa/configdir"

[[constraint]]
name = "github.com/NYTimes/gziphandler"
version = "v1.0.1"
5 changes: 4 additions & 1 deletion interfacer/src/browsh/raw_text_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down

0 comments on commit c0c6884

Please sign in to comment.