diff options
-rw-r--r-- | main.go | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -31,8 +31,9 @@ type ( var ( //go:embed static/* - assets embed.FS - serieRegex = regexp.MustCompile(`(?P<serie>.+) (?P<number>[0-9abc]+) \- (?P<title>.+)`) + assets embed.FS + serieRegex = regexp.MustCompile(`(?P<serie>.+) (?P<number>[0-9abc]+) \- (?P<title>.+)`) + errNotFound = errors.New("not found") ) var ( @@ -164,7 +165,12 @@ func handleError(next errorRequestHandler) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if err := next(w, r); err != nil { slog.ErrorContext(r.Context(), "Error", "error", err.Error()) - w.WriteHeader(http.StatusInternalServerError) + + if errors.Is(err, errNotFound) { + w.WriteHeader(http.StatusNotFound) + } else { + w.WriteHeader(http.StatusInternalServerError) + } } } } @@ -236,6 +242,12 @@ func view(w http.ResponseWriter, r *http.Request) error { } func podcast(w http.ResponseWriter, r *http.Request) error { + + if r.URL.Path != "/" { + return errNotFound + + } + xml, err := fetchXML(r.Context()) if err != nil { return err |