Created
June 8, 2014 20:53
-
-
Save cmelbye/a39456914ba6d4bc960a 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
package main | |
import ( | |
"bytes" | |
"net/http" | |
"appengine" | |
"appengine/urlfetch" | |
) | |
func MyHandler(w http.ResponseWriter, req *http.Request) { | |
c := appengine.NewContext(req) | |
body := []byte("Insert bytes here") | |
uploadreq, _ := http.NewRequest("PUT", "https://some.api.url/some/path", bytes.NewReader(body)) | |
client := urlfetch.Client(c) | |
err := client.Do(uploadreq) | |
if err != nil { | |
// Handle error | |
} | |
// "Insert bytes here" bytes were stored in memory twice | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment