Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support/http: remove behind proxy option for muxes #2051

Merged
merged 2 commits into from
Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/bridge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func NewApp(config config.Config, migrateFlag bool, versionFlag bool, version st

// Serve starts the server
func (a *App) Serve() {
mux := supportHttp.NewAPIMux(false)
mux := supportHttp.NewAPIMux()

// Middlewares
headers := make(http.Header)
Expand Down
4 changes: 2 additions & 2 deletions services/compliance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func NewApp(config config.Config, migrateFlag bool, versionFlag bool, version st
// Serve starts the server
func (a *App) Serve() {
// External endpoints
external := supportHttp.NewAPIMux(false)
external := supportHttp.NewAPIMux()

// Middlewares
headers := http.Header{}
Expand All @@ -195,7 +195,7 @@ func (a *App) Serve() {
}()

// Internal endpoints
internal := supportHttp.NewAPIMux(false)
internal := supportHttp.NewAPIMux()

internal.Use(supportHttp.StripTrailingSlashMiddleware("/admin"))
internal.Use(supportHttp.HeadersMiddleware(headers, "/admin/"))
Expand Down
2 changes: 1 addition & 1 deletion services/federation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func initDriver(cfg Config) (federation.Driver, error) {
}

func initMux(driver federation.Driver) *chi.Mux {
mux := http.NewAPIMux(false)
mux := http.NewAPIMux()

fed := &federation.Handler{
Driver: driver,
Expand Down
2 changes: 1 addition & 1 deletion services/friendbot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func run(cmd *cobra.Command, args []string) {
}

func initRouter(fb *internal.Bot) *chi.Mux {
mux := http.NewAPIMux(false)
mux := http.NewAPIMux()

handler := &internal.FriendbotHandler{Friendbot: fb}
mux.Get("/", handler.Handle)
Expand Down
10 changes: 3 additions & 7 deletions support/http/mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ import (

// NewMux returns a new server mux configured with the common defaults used across all
// stellar services.
func NewMux(behindProxy bool) *chi.Mux {
func NewMux() *chi.Mux {
mux := chi.NewMux()

if behindProxy {
mux.Use(middleware.RealIP)
}

mux.Use(middleware.RequestID)
mux.Use(middleware.Recoverer)
mux.Use(LoggingMiddleware)
Expand All @@ -24,8 +20,8 @@ func NewMux(behindProxy bool) *chi.Mux {

// NewAPIMux returns a new server mux configured with the common defaults used for a web API in
// stellar.
func NewAPIMux(behindProxy bool) *chi.Mux {
mux := NewMux(behindProxy)
func NewAPIMux() *chi.Mux {
mux := NewMux()

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