Last active
August 30, 2017 20:18
-
-
Save mcastilho/b83fac4fde8edd1d39619ff1d550b78a 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 payloadHandler(w http.ResponseWriter, r *http.Request) { | |
if r.Method != "POST" { | |
w.WriteHeader(http.StatusMethodNotAllowed) | |
return | |
} | |
// Read the body into a string for json decoding | |
var content = &PayloadCollection{} | |
err := json.NewDecoder(io.LimitReader(r.Body, MaxLength)).Decode(&content) | |
if err != nil { | |
w.Header().Set("Content-Type", "application/json; charset=UTF-8") | |
w.WriteHeader(http.StatusBadRequest) | |
return | |
} | |
// Go through each payload and queue items individually to be posted to S3 | |
for _, payload := range content.Payloads { | |
go payload.UploadToS3() // <----- DON'T DO THIS | |
} | |
w.WriteHeader(http.StatusOK) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment