mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
Take Path fragment from URL instead of whole URL.
This also makes better error handling in case a asset couldn't be found in the files map.
This commit is contained in:
parent
bf197baaf9
commit
17f622bd6e
|
@ -3,6 +3,7 @@ package blob
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -20,7 +21,11 @@ var mimeMap = map[string]string{
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetFile(bucket string, name string) ([]byte, error) {
|
func GetFile(bucket string, name string) ([]byte, error) {
|
||||||
reader := bytes.NewReader(files[bucket][name])
|
blob, ok := files[bucket][name]
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("Could not find %s/%s. Missing/updated files.go?", bucket, name)
|
||||||
|
}
|
||||||
|
reader := bytes.NewReader(blob)
|
||||||
gz, err := gzip.NewReader(reader)
|
gz, err := gzip.NewReader(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -36,7 +41,7 @@ func GetFile(bucket string, name string) ([]byte, error) {
|
||||||
type Handler struct{}
|
type Handler struct{}
|
||||||
|
|
||||||
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
name := r.URL.String()
|
name := r.URL.Path
|
||||||
if name == "" {
|
if name == "" {
|
||||||
name = "index.html"
|
name = "index.html"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue