diff options
-rw-r--r-- | website.go | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -100,7 +100,9 @@ func handleGrill(w http.ResponseWriter, r *http.Request) { grills, err := ioutil.ReadDir("static/grill/") if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) - return + } else if len(grills) == 0 { + http.Error(w, "files not found", http.StatusNotFound) + } else { + http.Redirect(w, r, "/static/grill/"+grills[rand.Intn(len(grills))].Name(), http.StatusFound) } - http.Redirect(w, r, "/static/grill/"+grills[rand.Intn(len(grills))].Name(), http.StatusFound) } |