where prefix is like "/" or "/s3/" for e.g. "/camli/" or "/s3/camli/*"
(prefix, baseURL string, storage blobserver.Storage, hf blobserver.FindHandlerByTyper)
| 161 | |
| 162 | // where prefix is like "/" or "/s3/" for e.g. "/camli/" or "/s3/camli/*" |
| 163 | func makeCamliHandler(prefix, baseURL string, storage blobserver.Storage, hf blobserver.FindHandlerByTyper) http.Handler { |
| 164 | if !strings.HasSuffix(prefix, "/") { |
| 165 | panic("expected prefix to end in slash") |
| 166 | } |
| 167 | baseURL = strings.TrimRight(baseURL, "/") |
| 168 | |
| 169 | canLongPoll := true |
| 170 | // TODO(bradfitz): set to false if this is App Engine, or provide some way to disable |
| 171 | |
| 172 | storageConfig := &storageAndConfig{ |
| 173 | storage, |
| 174 | &blobserver.Config{ |
| 175 | Writable: true, |
| 176 | Readable: true, |
| 177 | Deletable: false, |
| 178 | URLBase: baseURL + prefix[:len(prefix)-1], |
| 179 | CanLongPoll: canLongPoll, |
| 180 | HandlerFinder: hf, |
| 181 | }, |
| 182 | } |
| 183 | return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { |
| 184 | action, err := parseCamliPath(req.URL.Path[len(prefix)-1:]) |
| 185 | if err != nil { |
| 186 | log.Printf("Invalid request for method %q, path %q", |
| 187 | req.Method, req.URL.Path) |
| 188 | unsupportedHandler(rw, req) |
| 189 | return |
| 190 | } |
| 191 | handler := auth.RequireAuth(camliHandlerUsingStorage(req, action, storageConfig)) |
| 192 | handler.ServeHTTP(rw, req) |
| 193 | }) |
| 194 | } |
| 195 | |
| 196 | func (hl *handlerLoader) FindHandlerByType(htype string) (prefix string, handler interface{}, err error) { |
| 197 | nFound := 0 |
no test coverage detected