From 74ca0cac135fc4a55a2d26a5646bbe228a28a030 Mon Sep 17 00:00:00 2001 From: Bora Alper Date: Mon, 27 Aug 2018 20:25:17 +0300 Subject: [PATCH] magneticow: api: return 404 when the resource is not found --- cmd/magneticow/api.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/magneticow/api.go b/cmd/magneticow/api.go index b4daf1f..aba6bf3 100644 --- a/cmd/magneticow/api.go +++ b/cmd/magneticow/api.go @@ -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