Change 404 to 500 on error and fix method for removing episodes

This commit is contained in:
gmemstr 2017-09-06 20:03:24 -07:00
parent 6916e41cfc
commit 99f2893980
2 changed files with 8 additions and 5 deletions

View file

@ -76,9 +76,12 @@ func CreateEpisode(w http.ResponseWriter, r *http.Request) {
}
}
func RemoveEpisode(episode string) {
func RemoveEpisode(w http.ResponseWriter, r *http.Request) {
// Episode should be the full MP3 filename
// Remove MP3 first
r.ParseMultipartForm(32 << 20)
episode := strings.Join(r.Form["episode"],"")
os.Remove(episode)
sn := strings.Replace(episode, ".mp3", "_SHOWNOTES.md", 2)
os.Remove(sn)

View file

@ -48,8 +48,8 @@ func HomeHandler(w http.ResponseWriter, r *http.Request) {
if err == nil {
w.Write(data)
} else {
w.WriteHeader(404)
w.Write([]byte("404 Something went wrong - " + http.StatusText(404)))
w.WriteHeader(500)
w.Write([]byte("500 Something went wrong - " + http.StatusText(500)))
}
}
@ -84,8 +84,8 @@ func AdminHandler(w http.ResponseWriter, r *http.Request) {
if err == nil {
w.Write(data)
} else {
w.WriteHeader(404)
w.Write([]byte("404 Something went wrong - " + http.StatusText(404)))
w.WriteHeader(500)
w.Write([]byte("500 Something went wrong - " + http.StatusText(500)))
}
}