Skip to content

Instantly share code, notes, and snippets.

@cmelbye
Created June 8, 2014 20:53
Show Gist options
  • Save cmelbye/a39456914ba6d4bc960a to your computer and use it in GitHub Desktop.
Save cmelbye/a39456914ba6d4bc960a to your computer and use it in GitHub Desktop.
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