2016-08-18 33 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

相關問題