MCPcopy Create free account
hub / github.com/golang/appengine / NewClient

Function NewClient

remote_api/client.go:39–67  ·  view source on GitHub ↗

NewClient returns a client for the given host. All communication will be performed over SSL unless the host is localhost.

(host string, client *http.Client)

Source from the content-addressed store, hash-verified

37// NewClient returns a client for the given host. All communication will
38// be performed over SSL unless the host is localhost.
39func NewClient(host string, client *http.Client) (*Client, error) {
40 // Add an appcfg header to outgoing requests.
41 wrapClient := new(http.Client)
42 *wrapClient = *client
43 t := client.Transport
44 if t == nil {
45 t = http.DefaultTransport
46 }
47 wrapClient.Transport = &headerAddingRoundTripper{t}
48
49 url := url.URL{
50 Scheme: "https",
51 Host: host,
52 Path: "/_ah/remote_api",
53 }
54 if host == "localhost" || strings.HasPrefix(host, "localhost:") {
55 url.Scheme = "http"
56 }
57 u := url.String()
58 appID, err := getAppID(wrapClient, u)
59 if err != nil {
60 return nil, fmt.Errorf("unable to contact server: %v", err)
61 }
62 return &Client{
63 hc: wrapClient,
64 url: u,
65 appID: appID,
66 }, nil
67}
68
69// NewContext returns a copy of parent that will cause App Engine API
70// calls to be sent to the client's remote host.

Callers 2

ExampleClientFunction · 0.85
NewRemoteContextFunction · 0.85

Calls 2

getAppIDFunction · 0.85
StringMethod · 0.45

Tested by 1

ExampleClientFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…