Static serves the static files from the provided http.FileSystem. The returned handler is already instrumented for Prometheus.
(root http.FileSystem, prefix string)
| 63 | // |
| 64 | // The returned handler is already instrumented for Prometheus. |
| 65 | func Static(root http.FileSystem, prefix string) http.Handler { |
| 66 | if prefix == "/" { |
| 67 | prefix = "" |
| 68 | } |
| 69 | |
| 70 | handler := server.StaticFileServer(root) |
| 71 | return InstrumentWithCounter( |
| 72 | "static", |
| 73 | http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 74 | r.URL.Path = r.URL.Path[len(prefix):] |
| 75 | handler.ServeHTTP(w, r) |
| 76 | }), |
| 77 | ) |
| 78 | } |
searching dependent graphs…