Skip to content

Instantly share code, notes, and snippets.

@astanway
Created November 5, 2013 01:24
Show Gist options
  • Save astanway/7312325 to your computer and use it in GitHub Desktop.
Save astanway/7312325 to your computer and use it in GitHub Desktop.
func Pummeler(schema interface{}, callback string, failedAttempts chan bool, pummelers chan int) {
pummelers <- 1
// Format request
jsonEncoded, err := json.Marshal(schema)
if err != nil {
log.Println("Could not encode JSON")
return
}
// TODO: Generate unique data on the fly
// Format post request
values := make(url.Values)
values.Set("data", string(jsonEncoded))
// Send data to client
resp, err := http.PostForm(callback, values)
if resp.StatusCode != 200 || err != nil {
failedAttempts <- true
return
}
pummelers <- -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment