MCPcopy Index your code
hub / github.com/perkeep/perkeep / camliHandlerUsingStorage

Function camliHandlerUsingStorage

pkg/serverinit/serverinit.go:123–160  ·  view source on GitHub ↗

action is the part following "/camli/" in the URL. It's either a string like "enumerate-blobs", "stat", "upload", or a blobref.

(req *http.Request, action string, storage blobserver.StorageConfiger)

Source from the content-addressed store, hash-verified

121// action is the part following "/camli/" in the URL. It's either a
122// string like "enumerate-blobs", "stat", "upload", or a blobref.
123func camliHandlerUsingStorage(req *http.Request, action string, storage blobserver.StorageConfiger) (http.Handler, auth.Operation) {
124 var handler http.Handler
125 op := auth.OpAll
126 switch req.Method {
127 case "GET", "HEAD":
128 switch action {
129 case "enumerate-blobs":
130 handler = handlers.CreateEnumerateHandler(storage)
131 op = auth.OpGet
132 case "stat":
133 handler = handlers.CreateStatHandler(storage)
134 case "ws":
135 handler = nil // TODO: handlers.CreateSocketHandler(storage)
136 op = auth.OpDiscovery // rest of operation auth checks done in handler
137 default:
138 handler = handlers.CreateGetHandler(storage)
139 op = auth.OpGet
140 }
141 case "POST":
142 switch action {
143 case "stat":
144 handler = handlers.CreateStatHandler(storage)
145 op = auth.OpStat
146 case "upload":
147 handler = handlers.CreateBatchUploadHandler(storage)
148 op = auth.OpUpload
149 case "remove":
150 handler = handlers.CreateRemoveHandler(storage)
151 }
152 case "PUT":
153 handler = handlers.CreatePutUploadHandler(storage)
154 op = auth.OpUpload
155 }
156 if handler == nil {
157 handler = http.HandlerFunc(unsupportedHandler)
158 }
159 return handler, op
160}
161
162// where prefix is like "/" or "/s3/" for e.g. "/camli/" or "/s3/camli/*"
163func makeCamliHandler(prefix, baseURL string, storage blobserver.Storage, hf blobserver.FindHandlerByTyper) http.Handler {

Callers 1

makeCamliHandlerFunction · 0.85

Calls 6

CreateEnumerateHandlerFunction · 0.92
CreateStatHandlerFunction · 0.92
CreateGetHandlerFunction · 0.92
CreateBatchUploadHandlerFunction · 0.92
CreateRemoveHandlerFunction · 0.92
CreatePutUploadHandlerFunction · 0.92

Tested by

no test coverage detected