mirror of https://github.com/perkeep/perkeep.git
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:
parent
6b88e2a73f
commit
3d5c28511f
|
@ -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:
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue