Created
July 3, 2015 13:41
-
-
Save janstenpickle/975358c427e8af844ae7 to your computer and use it in GitHub Desktop.
Nic Cage Gif Randomiser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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