Skip to content

Commit

Permalink
Move noroute store to it's own package
Browse files Browse the repository at this point in the history
  • Loading branch information
tino committed Dec 6, 2017
1 parent 883be35 commit 81ea194
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -418,7 +419,7 @@ func watchNoRouteHTML(cfg *config.Config) {
if next == last {
continue
}
route.SetHTML(next)
noroute.SetHTML(next)
last = next
}
}
Expand Down
2 changes: 1 addition & 1 deletion route/no_route.go → noroute/no_route.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package route
package noroute

import (
"log"
Expand Down
3 changes: 2 additions & 1 deletion proxy/http_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -77,7 +78,7 @@ func TestProxyRequestIDHeader(t *testing.T) {

func TestProxyNoRouteHTML(t *testing.T) {
want := "<html>503</html>"
route.SetHTML(want)
noroute.SetHTML(want)
proxy := httptest.NewServer(&HTTPProxy{
Transport: http.DefaultTransport,
Lookup: func(*http.Request) *route.Target { return nil },
Expand Down
3 changes: 2 additions & 1 deletion proxy/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions registry/static/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

0 comments on commit 81ea194

Please sign in to comment.