2016-08-18 3 views

ответ

0

Я не использовал его так извинения, если это не работает. По GAE's docs вы, вероятно, хотите использовать urlfetch, чтобы получить что-то вроде *http.Client (нотабене в context пакет является стандартным в только что выпущенном Go 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.

Смежные вопросы