MCPcopy
hub / github.com/perkeep/perkeep / ServeStaticFile

Function ServeStaticFile

pkg/server/ui.go:484–497  ·  view source on GitHub ↗

ServeStaticFile serves file from the root virtual filesystem.

(rw http.ResponseWriter, req *http.Request, root fs.FS, file string)

Source from the content-addressed store, hash-verified

482
483// ServeStaticFile serves file from the root virtual filesystem.
484func ServeStaticFile(rw http.ResponseWriter, req *http.Request, root fs.FS, file string) {
485 f, err := root.Open(file)
486 if err != nil {
487 http.NotFound(rw, req)
488 log.Printf("Failed to open file %q from embedded resources: %v", file, err)
489 return
490 }
491 defer f.Close()
492 var modTime time.Time
493 if fi, err := f.Stat(); err == nil {
494 modTime = fi.ModTime()
495 }
496 http.ServeContent(rw, req, file, modTime, f.(io.ReadSeeker))
497}
498
499func (ui *UIHandler) discovery() *camtypes.UIDiscovery {
500 pubRoots := map[string]*camtypes.PublishRootDiscovery{}

Callers 4

serveHTTPMethod · 0.92
ServeHTTPMethod · 0.85
ServeHTTPMethod · 0.85
serveFromDiskOrStaticMethod · 0.85

Calls 5

PrintfMethod · 0.80
OpenMethod · 0.65
CloseMethod · 0.65
StatMethod · 0.65
ModTimeMethod · 0.45

Tested by

no test coverage detected