MCPcopy
hub / github.com/perkeep/perkeep / serveClosure

Method serveClosure

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

Source from the content-addressed store, hash-verified

612}
613
614func (ui *UIHandler) serveClosure(rw http.ResponseWriter, req *http.Request) {
615 suffix := httputil.PathSuffix(req)
616 if ui.closureHandler == nil {
617 log.Printf("%v not served: closure handler is nil", suffix)
618 http.NotFound(rw, req)
619 return
620 }
621 m := closurePattern.FindStringSubmatch(suffix)
622 if m == nil {
623 httputil.ErrorRouting(rw, req)
624 return
625 }
626 req.URL.Path = "/" + m[1]
627 ui.closureHandler.ServeHTTP(rw, req)
628}
629
630// serveFromDiskOrStatic matches rx against req's path and serves the match either from disk (if non-nil) or from static (embedded in the binary).
631func (ui *UIHandler) serveFromDiskOrStatic(rw http.ResponseWriter, req *http.Request, rx *regexp.Regexp,

Callers 1

ServeHTTPMethod · 0.95

Calls 4

PathSuffixFunction · 0.92
ErrorRoutingFunction · 0.92
PrintfMethod · 0.80
ServeHTTPMethod · 0.45

Tested by

no test coverage detected