MCPcopy
hub / github.com/perkeep/perkeep / ServeHTTP

Method ServeHTTP

pkg/server/app/app.go:82–106  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

80}
81
82func (a *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
83 if r.URL.Path == a.masterqueryURLPath {
84 a.handleMasterQuery(w, r)
85 return
86 }
87 if a.configURLPath != "" && r.URL.Path == a.configURLPath {
88 if a.auth.AllowedAccess(r)&auth.OpGet == auth.OpGet {
89 camhttputil.ReturnJSON(w, a.appConfig)
90 } else {
91 auth.SendUnauthorized(w, r)
92 }
93 return
94 }
95 trimmedPath := strings.TrimPrefix(r.URL.Path, a.prefix)
96 if strings.HasPrefix(trimmedPath, "/search") {
97 a.handleSearch(w, r)
98 return
99 }
100
101 if a.proxy == nil {
102 http.Error(w, "no proxy for the app", 500)
103 return
104 }
105 a.proxy.ServeHTTP(w, r)
106}
107
108// handleMasterQuery allows an app to register the master query that defines the
109// domain limiting all subsequent search queries.

Callers

nothing calls this directly

Calls 6

handleMasterQueryMethod · 0.95
handleSearchMethod · 0.95
SendUnauthorizedFunction · 0.92
HasPrefixMethod · 0.80
AllowedAccessMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected