Skip to content

Instantly share code, notes, and snippets.

@janstenpickle
Created July 3, 2015 13:41
Show Gist options
  • Save janstenpickle/975358c427e8af844ae7 to your computer and use it in GitHub Desktop.
Save janstenpickle/975358c427e8af844ae7 to your computer and use it in GitHub Desktop.
Nic Cage Gif Randomiser
package main
import (
"net/http"
ghttp "github.com/gorilla/http"
"math/rand"
"fmt"
"os"
)
func randomCage() (string) {
i := []string{"HU6xsjD.gif","7OG2fIf.gif", "PU905S9.gif"}
return i[rand.Intn(len(i))]
}
func proxy(w http.ResponseWriter, r *http.Request) {
ghttp.Get(w, "http://i.imgur.com/" + randomCage())
}
func main() {
rand.Seed(41)
http.HandleFunc("/", proxy)
bind := fmt.Sprintf("%s:%s", os.Getenv("HOST"), os.Getenv("PORT"))
http.ListenAndServe(bind, nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment