Fixup the proxy, strip down go.mod. Win bigly

This commit is contained in:
Asim Aslam
2019-06-07 13:42:39 +01:00
parent d65393a799
commit 9e23855c37
11 changed files with 116 additions and 555 deletions

View File

@@ -20,7 +20,7 @@ func (t *testHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`{"hello": "world"}`))
}
func TestHTTPRouter(t *testing.T) {
func TestHTTPProxy(t *testing.T) {
c, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatal(err)
@@ -47,7 +47,7 @@ func TestHTTPRouter(t *testing.T) {
http.Handle("/", new(testHandler))
// new proxy
p := NewSingleHostRouter(url)
p := NewSingleHostProxy(url)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@@ -91,32 +91,3 @@ func TestHTTPRouter(t *testing.T) {
}
}
}
func TestHTTPRouterOptions(t *testing.T) {
// test endpoint
service := NewService(
WithBackend("http://foo.bar"),
)
r := service.Server().Options().Router
httpRouter, ok := r.(*Router)
if !ok {
t.Fatal("Expected http router to be installed")
}
if httpRouter.Backend != "http://foo.bar" {
t.Fatalf("Expected endpoint http://foo.bar got %v", httpRouter.Backend)
}
// test router
service = NewService(
WithRouter(&Router{Backend: "http://foo2.bar"}),
)
r = service.Server().Options().Router
httpRouter, ok = r.(*Router)
if !ok {
t.Fatal("Expected http router to be installed")
}
if httpRouter.Backend != "http://foo2.bar" {
t.Fatalf("Expected endpoint http://foo2.bar got %v", httpRouter.Backend)
}
}