diff --git a/util/route/route_test.go b/util/route/route_test.go deleted file mode 100644 index 734682e98..000000000 --- a/util/route/route_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package route - -import ( - "net/http" - "net/http/httptest" - "testing" -) - -func TestRedirect(t *testing.T) { - router := New().WithPrefix("/test/prefix") - w := httptest.NewRecorder() - r, err := http.NewRequest("GET", "http://localhost:9090/foo", nil) - if err != nil { - t.Fatalf("Error building test request: %s", err) - } - - router.Redirect(w, r, "/some/endpoint", http.StatusFound) - if w.Code != http.StatusFound { - t.Fatalf("Unexpected redirect status code: got %d, want %d", w.Code, http.StatusFound) - } - - want := "/test/prefix/some/endpoint" - got := w.Header()["Location"][0] - if want != got { - t.Fatalf("Unexpected redirect location: got %s, want %s", got, want) - } -} diff --git a/util/route/route.go b/vendor/github.com/prometheus/common/route/route.go similarity index 95% rename from util/route/route.go rename to vendor/github.com/prometheus/common/route/route.go index 9dd059320..1c41b03af 100644 --- a/util/route/route.go +++ b/vendor/github.com/prometheus/common/route/route.go @@ -80,6 +80,11 @@ func (r *Router) Del(path string, h http.HandlerFunc) { r.rtr.DELETE(r.prefix+path, handle(h)) } +// Put registers a new PUT route. +func (r *Router) Put(path string, h http.HandlerFunc) { + r.rtr.PUT(r.prefix+path, handle(h)) +} + // Post registers a new POST route. func (r *Router) Post(path string, h http.HandlerFunc) { r.rtr.POST(r.prefix+path, handle(h)) diff --git a/vendor/vendor.json b/vendor/vendor.json index 39396673a..6f7960f92 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -82,6 +82,11 @@ "revision": "c33395bbc758c8d25735ec7036d66b342084ae35", "revisionTime": "2015-08-25T14:37:19+02:00" }, + { + "path": "github.com/prometheus/common/route", + "revision": "ffd5d0f2976124c788687ec2ac194f5479e1f9c2", + "revisionTime": "2015-09-24T17:06:36+02:00" + }, { "path": "github.com/prometheus/log", "revision": "439e5db48fbb50ebbaf2c816030473a62f505f55", diff --git a/web/api/legacy/api.go b/web/api/legacy/api.go index e4afcfdbf..40aede464 100644 --- a/web/api/legacy/api.go +++ b/web/api/legacy/api.go @@ -18,11 +18,11 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" + "github.com/prometheus/common/route" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/storage/local" "github.com/prometheus/prometheus/util/httputil" - "github.com/prometheus/prometheus/util/route" ) // API manages the /api HTTP endpoint. diff --git a/web/api/legacy/api_test.go b/web/api/legacy/api_test.go index 70a760546..ce0ce91d8 100644 --- a/web/api/legacy/api_test.go +++ b/web/api/legacy/api_test.go @@ -22,10 +22,10 @@ import ( "time" "github.com/prometheus/common/model" + "github.com/prometheus/common/route" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/storage/local" - "github.com/prometheus/prometheus/util/route" ) // This is a bit annoying. On one hand, we have to choose a current timestamp diff --git a/web/api/v1/api.go b/web/api/v1/api.go index ba20a2b13..d0deaba80 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -11,13 +11,13 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" + "github.com/prometheus/common/route" "golang.org/x/net/context" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/storage/local" "github.com/prometheus/prometheus/storage/metric" "github.com/prometheus/prometheus/util/httputil" - "github.com/prometheus/prometheus/util/route" "github.com/prometheus/prometheus/util/strutil" ) diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index 1b1c497e1..bc3d89da6 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -13,10 +13,10 @@ import ( "time" "github.com/prometheus/common/model" + "github.com/prometheus/common/route" "golang.org/x/net/context" "github.com/prometheus/prometheus/promql" - "github.com/prometheus/prometheus/util/route" ) func TestEndpoints(t *testing.T) { diff --git a/web/blob/blob.go b/web/blob/blob.go index f5d9bac2e..faaae3a13 100644 --- a/web/blob/blob.go +++ b/web/blob/blob.go @@ -8,9 +8,8 @@ import ( "net/http" "strings" + "github.com/prometheus/common/route" "github.com/prometheus/log" - - "github.com/prometheus/prometheus/util/route" ) // Sub-directories for templates and static content. diff --git a/web/web.go b/web/web.go index 8f1c2a6e0..65673074c 100644 --- a/web/web.go +++ b/web/web.go @@ -33,6 +33,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/model" + "github.com/prometheus/common/route" "github.com/prometheus/log" "github.com/prometheus/prometheus/config" @@ -42,7 +43,6 @@ import ( "github.com/prometheus/prometheus/storage/local" "github.com/prometheus/prometheus/template" "github.com/prometheus/prometheus/util/httputil" - "github.com/prometheus/prometheus/util/route" "github.com/prometheus/prometheus/version" "github.com/prometheus/prometheus/web/api/legacy" "github.com/prometheus/prometheus/web/api/v1"