aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--website.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/website.go b/website.go
index be962e6..7cc32c1 100644
--- a/website.go
+++ b/website.go
@@ -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)
}