From d3fcb7b859e2c4aa26de96f793f65ec94a7bb366 Mon Sep 17 00:00:00 2001 From: Mark van der Velden Date: Mon, 16 Oct 2017 14:05:11 +0200 Subject: [PATCH] Allowing empty hosts to match against. --- main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 28e4be2..52d2b39 100644 --- a/main.go +++ b/main.go @@ -100,8 +100,15 @@ func newProxy(l log.Logger, backend *url.URL) *httputil.ReverseProxy { type httpHandler func(h http.Handler) http.Handler func decorateHandler(l log.Logger, h http.Handler, b *ratelimit.Bucket) http.Handler { - decorators := []httpHandler{ - handlers.NewValidateURLParameter(l, allowedHosts), + decorators := []httpHandler{} + + if len(allowedHosts) > 0 { + decorators = append( + decorators, + handlers.NewValidateURLParameter( + l, + allowedHosts, + )) } if len(allowedImaginaryParams) > 0 {