2016-08-18 30 views

回答

0

我还没有使用它,所以如果这不起作用道歉。据GAE's docs你可能想使用urlfetch获得*http.Client像(注:该context包是一个标准刚刚发布转至1.7):

import (
    "context" // Go 1.7 
    // "golang.org/x/net/context" // Go < 1.7 
    "google.golang.org/appengine/urlfetch" 
) 

client := urlfetch.Client(context.Background()) 
resp, err := client.Get("http://example.com/") 
1

使用urlfetch包。

ctx := appengine.NewContext(r) // r is the *http.Request arg to the handler 
client := urlfetch.Client(ctx) 
resp, err := client.Get("http://example.com") 
if err != nil { 
    // handle the error 
} 
body := resp.Body // body is an io.Reader containing the response body 

Here's a complete example

相关问题