Skip to content

Instantly share code, notes, and snippets.

@astanway
Last active December 28, 2015 01:58
Show Gist options
  • Save astanway/7423963 to your computer and use it in GitHub Desktop.
Save astanway/7423963 to your computer and use it in GitHub Desktop.
package main
import (
"io"
"log"
"net/http"
"strings"
)
func CallbackHandler(w http.ResponseWriter, r *http.Request) {
log.Println("Got secret key")
log.Println(r.Method)
if r.Method == "GET" {
log.Println("Got secret key")
r.ParseForm()
key, _ := r.Form["key"]
joined := strings.Join(key, ", ")
io.WriteString(w, joined)
log.Println(key)
} else {
log.Println("zomg")
}
}
func RequestKey() {
log.Println("ahem")
resp, err := http.Get("http://google.com")
if err != nil {
log.Println("Couldn't subscribe")
return
}
log.Println(resp)
defer resp.Body.Close()
}
func SetUpHandlers() {
log.Println("hi")
http.HandleFunc("/callback", CallbackHandler)
http.ListenAndServe(":5000", nil)
log.Println("hi")
}
func main() {
go SetUpHandlers()
go RequestKey()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment