mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
web: fix asset paths for Windows platforms (#4616)
* web: fix asset paths for Windows platforms Signed-off-by: Simon Pasquier <spasquie@redhat.com> * web: add tests Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
16532a7111
commit
2d7f562ed6
|
@ -264,7 +264,7 @@ func New(logger log.Logger, o *Options) *Handler {
|
||||||
router.Get("/consoles/*filepath", readyf(h.consoles))
|
router.Get("/consoles/*filepath", readyf(h.consoles))
|
||||||
|
|
||||||
router.Get("/static/*filepath", func(w http.ResponseWriter, r *http.Request) {
|
router.Get("/static/*filepath", func(w http.ResponseWriter, r *http.Request) {
|
||||||
r.URL.Path = filepath.Join("/static", route.Param(r.Context(), "filepath"))
|
r.URL.Path = path.Join("/static", route.Param(r.Context(), "filepath"))
|
||||||
fs := http.FileServer(ui.Assets)
|
fs := http.FileServer(ui.Assets)
|
||||||
fs.ServeHTTP(w, r)
|
fs.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
|
@ -825,7 +825,7 @@ func (h *Handler) getTemplate(name string) (string, error) {
|
||||||
var tmpl string
|
var tmpl string
|
||||||
|
|
||||||
appendf := func(name string) error {
|
appendf := func(name string) error {
|
||||||
f, err := ui.Assets.Open(filepath.Join("/templates", name))
|
f, err := ui.Assets.Open(path.Join("/templates", name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,12 @@ func TestReadyAndHealthy(t *testing.T) {
|
||||||
RoutePrefix: "/",
|
RoutePrefix: "/",
|
||||||
EnableAdminAPI: true,
|
EnableAdminAPI: true,
|
||||||
TSDB: func() *libtsdb.DB { return db },
|
TSDB: func() *libtsdb.DB { return db },
|
||||||
|
ExternalURL: &url.URL{
|
||||||
|
Scheme: "http",
|
||||||
|
Host: "localhost:9090",
|
||||||
|
Path: "/",
|
||||||
|
},
|
||||||
|
Version: &PrometheusVersion{},
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.Flags = map[string]string{}
|
opts.Flags = map[string]string{}
|
||||||
|
@ -138,6 +144,11 @@ func TestReadyAndHealthy(t *testing.T) {
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||||
|
|
||||||
|
resp, err = http.Get("http://localhost:9090/graph")
|
||||||
|
|
||||||
|
testutil.Ok(t, err)
|
||||||
|
testutil.Equals(t, http.StatusServiceUnavailable, resp.StatusCode)
|
||||||
|
|
||||||
resp, err = http.Post("http://localhost:9090/api/v2/admin/tsdb/snapshot", "", strings.NewReader(""))
|
resp, err = http.Post("http://localhost:9090/api/v2/admin/tsdb/snapshot", "", strings.NewReader(""))
|
||||||
|
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
@ -166,6 +177,11 @@ func TestReadyAndHealthy(t *testing.T) {
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||||
|
|
||||||
|
resp, err = http.Get("http://localhost:9090/graph")
|
||||||
|
|
||||||
|
testutil.Ok(t, err)
|
||||||
|
testutil.Equals(t, http.StatusOK, resp.StatusCode)
|
||||||
|
|
||||||
resp, err = http.Post("http://localhost:9090/api/v2/admin/tsdb/snapshot", "", strings.NewReader(""))
|
resp, err = http.Post("http://localhost:9090/api/v2/admin/tsdb/snapshot", "", strings.NewReader(""))
|
||||||
|
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
|
Loading…
Reference in a new issue