mirror of
https://github.com/prometheus/prometheus
synced 2024-12-27 17:13:22 +00:00
Merge pull request #1113 from prometheus/router
Switch to common/route package
This commit is contained in:
commit
656b2e2109
@ -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)
|
||||
}
|
||||
}
|
5
util/route/route.go → vendor/github.com/prometheus/common/route/route.go
generated
vendored
5
util/route/route.go → vendor/github.com/prometheus/common/route/route.go
generated
vendored
@ -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))
|
5
vendor/vendor.json
vendored
5
vendor/vendor.json
vendored
@ -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",
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
)
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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.
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user