Log instead of panicking in HTTP handler on GET to /index/ (no Fetcher)

And change two Camlistore instances to Perkeep.

Change-Id: Id515480ecdc0c997e1700204d63ef4cc6a8c8cc4
This commit is contained in:
Brad Fitzpatrick 2018-04-27 13:27:56 -07:00
parent 6b88e2a73f
commit 3d5c28511f
2 changed files with 9 additions and 2 deletions

View File

@ -20,6 +20,7 @@ package gethandler // import "perkeep.org/pkg/blobserver/gethandler"
import (
"fmt"
"io"
"log"
"net/http"
"os"
"regexp"
@ -63,6 +64,12 @@ func (h *Handler) ServeHTTP(conn http.ResponseWriter, req *http.Request) {
// ServeBlobRef serves a blob.
func ServeBlobRef(rw http.ResponseWriter, req *http.Request, blobRef blob.Ref, fetcher blob.Fetcher) {
ctx := req.Context()
if fetcher == nil {
log.Printf("gethandler: no fetcher configured for %s (ref=%v)", req.URL.Path, blobRef)
rw.WriteHeader(http.StatusNotFound)
fmt.Fprintf(rw, "no fetcher configured", blobRef)
return
}
rc, size, err := fetcher.Fetch(ctx, blobRef)
switch err {
case nil:

View File

@ -86,7 +86,7 @@ type handlerLoader struct {
}
// A HandlerInstaller is anything that can register an HTTP Handler at
// a prefix path. Both *http.ServeMux and camlistore.org/pkg/webserver.Server
// a prefix path. Both *http.ServeMux and perkeep.org/pkg/webserver.Server
// implement HandlerInstaller.
type HandlerInstaller interface {
Handle(path string, h http.Handler)
@ -109,7 +109,7 @@ func parseCamliPath(path string) (action string, err error) {
}
func unsupportedHandler(conn http.ResponseWriter, req *http.Request) {
httputil.BadRequestError(conn, "Unsupported camlistore path or method.")
httputil.BadRequestError(conn, "Unsupported Perkeep path or method.")
}
func (s *storageAndConfig) Config() *blobserver.Config {