fix superfluous response.WriteHeader()

Signed-off-by: Odyssey346 <odyssey346@disroot.org>
This commit is contained in:
Odyssey346 2022-08-03 21:43:20 +02:00
parent c73b648451
commit b8075a7d96

View File

@ -77,7 +77,6 @@ func handleAnnouncementDeleteRequest(w http.ResponseWriter, r *http.Request) {
http.Error(w, "You need to provide the authorization token given to you by your system administrator in order to delete an announcement.", http.StatusUnauthorized) http.Error(w, "You need to provide the authorization token given to you by your system administrator in order to delete an announcement.", http.StatusUnauthorized)
return return
} else { } else {
w.WriteHeader(http.StatusOK)
if _, err := os.Stat("./static/announcements.json"); errors.Is(err, os.ErrNotExist) { if _, err := os.Stat("./static/announcements.json"); errors.Is(err, os.ErrNotExist) {
http.Error(w, "If you're gonna delete the annoucement, there has to be an announcement in the first place.", http.StatusNotFound) http.Error(w, "If you're gonna delete the annoucement, there has to be an announcement in the first place.", http.StatusNotFound)
return return
@ -87,6 +86,7 @@ func handleAnnouncementDeleteRequest(w http.ResponseWriter, r *http.Request) {
log.Fatal(err) log.Fatal(err)
} }
w.Write([]byte("Announcement deleted!")) w.Write([]byte("Announcement deleted!"))
w.WriteHeader(http.StatusOK)
return return
} }
} }