Skip to content

Commit

Permalink
Add response compression to horizon and federation
Browse files Browse the repository at this point in the history
  • Loading branch information
nullstyle committed Mar 28, 2018
1 parent 74a7175 commit 58bc4ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion services/federation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"goji.io"
"goji.io/pat"

"github.com/go-chi/chi/middleware"
"github.com/rs/cors"
"github.com/spf13/cobra"
"github.com/stellar/go/handlers/federation"
Expand Down Expand Up @@ -138,8 +139,9 @@ func initMux(driver federation.Driver) *goji.Mux {
})
mux.Use(c.Handler)
mux.Use(log.HTTPMiddleware)
mux.Use(middleware.DefaultCompress)

fed := &federation.Handler{driver}
fed := &federation.Handler{Driver: driver}

mux.Handle(pat.Get("/federation"), fed)
mux.Handle(pat.Get("/federation/"), fed)
Expand Down
3 changes: 3 additions & 0 deletions services/horizon/internal/init_web.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package horizon

import (
"compress/flate"
"database/sql"
"net/http"
"strings"

"github.com/PuerkitoBio/throttled"
"github.com/PuerkitoBio/throttled/store"
chimiddleware "github.com/go-chi/chi/middleware"
metrics "github.com/rcrowley/go-metrics"
"github.com/rs/cors"
"github.com/sebest/xff"
Expand Down Expand Up @@ -61,6 +63,7 @@ func initWebMiddleware(app *App) {
r.Use(requestMetricsMiddleware)
r.Use(RecoverMiddleware)
r.Use(middleware.AutomaticOptions)
r.Use(chimiddleware.Compress(flate.DefaultCompression, "application/hal+json"))

c := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
Expand Down

0 comments on commit 58bc4ff

Please sign in to comment.