magneticow: api: return 404 when the resource is not found

This commit is contained in:
Bora Alper 2018-08-27 20:25:17 +03:00
parent 4c4dc1c173
commit 74ca0cac13

View File

@ -107,6 +107,9 @@ func apiTorrentsInfohashHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
respondError(w, 500, "couldn't get torrent: %s", err.Error())
return
} else if torrent == nil {
respondError(w, 404, "not found")
return
}
// TODO: use plain Marshal
@ -134,6 +137,9 @@ func apiFilesInfohashHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
respondError(w, 500, "couldn't get files: %s", err.Error())
return
} else if files == nil {
respondError(w, 404, "not found")
return
}
// TODO: use plain Marshal