MCPcopy
hub / github.com/perkeep/perkeep / serveFileTree

Method serveFileTree

pkg/server/ui.go:588–612  ·  view source on GitHub ↗
(rw http.ResponseWriter, req *http.Request)

Source from the content-addressed store, hash-verified

586}
587
588func (ui *UIHandler) serveFileTree(rw http.ResponseWriter, req *http.Request) {
589 if ui.root.Storage == nil {
590 http.Error(rw, "No BlobRoot configured", 500)
591 return
592 }
593
594 suffix := httputil.PathSuffix(req)
595 m := treePattern.FindStringSubmatch(suffix)
596 if m == nil {
597 httputil.ErrorRouting(rw, req)
598 return
599 }
600
601 blobref, ok := blob.Parse(m[1])
602 if !ok {
603 http.Error(rw, "Invalid blobref", http.StatusBadRequest)
604 return
605 }
606
607 fth := &FileTreeHandler{
608 Fetcher: ui.root.Storage,
609 file: blobref,
610 }
611 fth.ServeHTTP(rw, req)
612}
613
614func (ui *UIHandler) serveClosure(rw http.ResponseWriter, req *http.Request) {
615 suffix := httputil.PathSuffix(req)

Callers 1

ServeHTTPMethod · 0.95

Calls 5

ServeHTTPMethod · 0.95
PathSuffixFunction · 0.92
ErrorRoutingFunction · 0.92
ParseFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected