From 6128615d04e8ba8abbcfcdaf449451b8d68892ca Mon Sep 17 00:00:00 2001 From: Alexander Rakoczy Date: Thu, 21 Oct 2021 12:45:19 -0400 Subject: not found --- cmd/server/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmd/server/main.go') diff --git a/cmd/server/main.go b/cmd/server/main.go index d00ea02..4c8238c 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "errors" "io" "io/fs" "log" @@ -29,7 +30,7 @@ func main() { if err != nil { log.Fatalf("storage.NewClient() = _, %v", err) } - b := cl.Bucket("i.dis.band") + b := cl.Bucket("i-dis-band-east4") http.Handle("/", fileServerHandler(internal.Static, image(b, http.HandlerFunc(home)))) log.Printf("Listening on %s\n", net.JoinHostPort(host, port)) log.Fatal(http.ListenAndServe(net.JoinHostPort(host, port), nil)) @@ -42,6 +43,10 @@ func image(b *storage.BucketHandle, next http.Handler) http.Handler { return } o, err := b.Object(strings.TrimPrefix(r.URL.Path, "/")).NewReader(r.Context()) + if errors.Is(err, storage.ErrObjectNotExist) { + http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) + return + } if err != nil { log.Printf("b.Object(%q) = %v", r.URL.Path, err) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) -- cgit v1.2.3-73-g0e29