diff --git a/main.go b/main.go
index 7a8d2a67604cdc163da9c1c6549593d046605745..728d32c4aa9d163391703880265af9a970019a74 100644
--- a/main.go
+++ b/main.go
@@ -31,8 +31,9 @@ )
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 @@ return nil
}
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