From 1c9d6da3900951179c12d7942eb149a4d9f11630 Mon Sep 17 00:00:00 2001 From: clsr Date: Thu, 16 Jun 2016 20:38:38 +0200 Subject: Move handleGrill from api.go to website.go --- website.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'website.go') diff --git a/website.go b/website.go index a917979..3cc30fc 100644 --- a/website.go +++ b/website.go @@ -92,3 +92,12 @@ func handlePage(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(os.Stderr, err) } } + +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 + } + http.Redirect(w, r, "/static/grill/"+grills[rand.Intn(len(grills))].Name(), http.StatusFound) +} -- cgit