diff options
author | clsr <clsr@clsr.net> | 2016-06-20 15:33:30 +0200 |
---|---|---|
committer | clsr <clsr@clsr.net> | 2016-06-20 15:33:30 +0200 |
commit | 26c6e8e8fb3a37344fba8438af54e2947a5e5b0b (patch) | |
tree | 9b251c11686b28acf19e585182ea93e82910a267 | |
parent | 0861d561839407ce63ccc56317ea74e52c457381 (diff) | |
download | gomf-26c6e8e8fb3a37344fba8438af54e2947a5e5b0b.tar.gz gomf-26c6e8e8fb3a37344fba8438af54e2947a5e5b0b.zip |
Handle empty /static/grill dirsv0.2.5
-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) } |