From 81ea194203669fe7bf43128905bfe5abd6e4162c Mon Sep 17 00:00:00 2001 From: Tino Date: Wed, 6 Dec 2017 21:46:22 +0100 Subject: [PATCH] Move noroute store to it's own package --- main.go | 3 ++- {route => noroute}/no_route.go | 2 +- proxy/http_integration_test.go | 3 ++- proxy/http_proxy.go | 3 ++- registry/static/backend.go | 4 ++-- 5 files changed, 9 insertions(+), 6 deletions(-) rename {route => noroute}/no_route.go (96%) diff --git a/main.go b/main.go index 53f60a75d..4de4b6830 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ import ( "github.com/fabiolb/fabio/exit" "github.com/fabiolb/fabio/logger" "github.com/fabiolb/fabio/metrics" + "github.com/fabiolb/fabio/noroute" "github.com/fabiolb/fabio/proxy" "github.com/fabiolb/fabio/proxy/tcp" "github.com/fabiolb/fabio/registry" @@ -418,7 +419,7 @@ func watchNoRouteHTML(cfg *config.Config) { if next == last { continue } - route.SetHTML(next) + noroute.SetHTML(next) last = next } } diff --git a/route/no_route.go b/noroute/no_route.go similarity index 96% rename from route/no_route.go rename to noroute/no_route.go index 5273eb241..613c66e64 100644 --- a/route/no_route.go +++ b/noroute/no_route.go @@ -1,4 +1,4 @@ -package route +package noroute import ( "log" diff --git a/proxy/http_integration_test.go b/proxy/http_integration_test.go index b5f55ac5a..efa80ed3f 100644 --- a/proxy/http_integration_test.go +++ b/proxy/http_integration_test.go @@ -20,6 +20,7 @@ import ( "github.com/fabiolb/fabio/config" "github.com/fabiolb/fabio/logger" + "github.com/fabiolb/fabio/noroute" "github.com/fabiolb/fabio/proxy/internal" "github.com/fabiolb/fabio/route" "github.com/pascaldekloe/goe/verify" @@ -77,7 +78,7 @@ func TestProxyRequestIDHeader(t *testing.T) { func TestProxyNoRouteHTML(t *testing.T) { want := "503" - route.SetHTML(want) + noroute.SetHTML(want) proxy := httptest.NewServer(&HTTPProxy{ Transport: http.DefaultTransport, Lookup: func(*http.Request) *route.Target { return nil }, diff --git a/proxy/http_proxy.go b/proxy/http_proxy.go index d0300188f..89314af71 100644 --- a/proxy/http_proxy.go +++ b/proxy/http_proxy.go @@ -14,6 +14,7 @@ import ( "github.com/fabiolb/fabio/config" "github.com/fabiolb/fabio/logger" "github.com/fabiolb/fabio/metrics" + "github.com/fabiolb/fabio/noroute" "github.com/fabiolb/fabio/proxy/gzip" "github.com/fabiolb/fabio/route" "github.com/fabiolb/fabio/uuid" @@ -64,7 +65,7 @@ func (p *HTTPProxy) ServeHTTP(w http.ResponseWriter, r *http.Request) { t := p.Lookup(r) if t == nil { w.WriteHeader(p.Config.NoRouteStatus) - html := route.GetHTML() + html := noroute.GetHTML() if html != "" { io.WriteString(w, html) } diff --git a/registry/static/backend.go b/registry/static/backend.go index 064d06569..98bf7091c 100644 --- a/registry/static/backend.go +++ b/registry/static/backend.go @@ -7,8 +7,8 @@ import ( "log" "github.com/fabiolb/fabio/config" + "github.com/fabiolb/fabio/noroute" "github.com/fabiolb/fabio/registry" - "github.com/fabiolb/fabio/route" ) type be struct { @@ -52,6 +52,6 @@ func (b *be) WatchNoRouteHTML() chan string { if err != nil { log.Printf("[WARN] Could not read NoRouteHTMLPath (%s)", b.cfg.NoRouteHTMLPath) } - route.SetHTML(string(data)) + noroute.SetHTML(string(data)) return make(chan string) }