Created
November 5, 2013 01:24
-
-
Save astanway/7312325 to your computer and use it in GitHub Desktop.
This file contains 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
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