MCPcopy Create free account
hub / github.com/prometheus/common / StaticFileServer

Function StaticFileServer

server/static_file_server.go:41–53  ·  view source on GitHub ↗
(root http.FileSystem)

Source from the content-addressed store, hash-verified

39}
40
41func StaticFileServer(root http.FileSystem) http.Handler {
42 return http.HandlerFunc(
43 func(w http.ResponseWriter, r *http.Request) {
44 fileExt := filepath.Ext(r.URL.Path)
45
46 if t, ok := mimeTypes[fileExt]; ok {
47 w.Header().Set("Content-Type", t)
48 }
49
50 http.FileServer(root).ServeHTTP(w, r)
51 },
52 )
53}

Callers 1

TestServeHttpFunction · 0.85

Calls 2

ServeHTTPMethod · 0.80
SetMethod · 0.45

Tested by 1

TestServeHttpFunction · 0.68