Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Add err check from GetTorrentById return in ApiViewHandler (#696)

This should give a better response to API users for when something is not found.
Cette révision appartient à :
nopjmp 2017-05-22 22:18:25 -05:00 révisé par ewhal
Parent af2850518c
révision 6cfaca1289

Voir le fichier

@ -92,6 +92,12 @@ func ApiViewHandler(w http.ResponseWriter, r *http.Request) {
id := vars["id"]
torrent, err := torrentService.GetTorrentById(id)
if err != nil {
http.Error(w, err.Error(), http.StatusNotFound)
return
}
b := torrent.ToJSON()
w.Header().Set("Content-Type", "application/json")
err = json.NewEncoder(w).Encode(b)