diff options
| author | Alexander Rakoczy <[email protected]> | 2021-10-21 12:45:19 -0400 |
|---|---|---|
| committer | Alexander Rakoczy <[email protected]> | 2021-10-21 12:45:19 -0400 |
| commit | 6128615d04e8ba8abbcfcdaf449451b8d68892ca (patch) | |
| tree | a49653abae290c68eb2a9937b4f5191a5ec0bb0a | |
| parent | 34fa0a9b4fd446b1a844020786a691fecc2f89d5 (diff) | |
not found
| -rw-r--r-- | cmd/server/main.go | 7 |
1 files changed, 6 insertions, 1 deletions
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) |
