OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package prod | |
6 | |
7 import ( | |
8 "time" | |
9 | |
10 "golang.org/x/net/context" | |
11 | |
12 "infra/gae/libs/gae" | |
13 | |
14 "google.golang.org/appengine" | |
15 ) | |
16 | |
17 // useGI adds a gae.GlobalInfo implementation to context, accessible | |
18 // by gae.GetGI(c) | |
19 func useGI(c context.Context) context.Context { | |
20 return gae.SetGIFactory(c, func(ci context.Context) gae.GlobalInfo { | |
21 return giImpl{ci} | |
22 }) | |
23 } | |
24 | |
25 type giImpl struct{ context.Context } | |
26 | |
27 func (g giImpl) AccessToken(scopes ...string) (token string, expiry time.Time, e
rr error) { | |
28 return appengine.AccessToken(g, scopes...) | |
29 } | |
30 func (g giImpl) AppID() string { | |
31 return appengine.AppID(g) | |
32 } | |
33 func (g giImpl) Datacenter() string { | |
34 return appengine.Datacenter(g) | |
35 } | |
36 func (g giImpl) DefaultVersionHostname() string { | |
37 return appengine.DefaultVersionHostname(g) | |
38 } | |
39 func (g giImpl) InstanceID() string { | |
40 return appengine.InstanceID() | |
41 } | |
42 func (g giImpl) IsDevAppServer() bool { | |
43 return appengine.IsDevAppServer() | |
44 } | |
45 func (g giImpl) IsOverQuota(err error) bool { | |
46 return appengine.IsOverQuota(err) | |
47 } | |
48 func (g giImpl) IsTimeoutError(err error) bool { | |
49 return appengine.IsTimeoutError(err) | |
50 } | |
51 func (g giImpl) ModuleHostname(module, version, instance string) (string, error)
{ | |
52 return appengine.ModuleHostname(g, module, version, instance) | |
53 } | |
54 func (g giImpl) ModuleName() (name string) { | |
55 return appengine.ModuleName(g) | |
56 } | |
57 func (g giImpl) Namespace(namespace string) (context.Context, error) { | |
58 return appengine.Namespace(g, namespace) | |
59 } | |
60 func (g giImpl) PublicCertificates() ([]gae.GICertificate, error) { | |
61 certs, err := appengine.PublicCertificates(g) | |
62 if err != nil { | |
63 return nil, err | |
64 } | |
65 ret := make([]gae.GICertificate, len(certs)) | |
66 for i, c := range certs { | |
67 ret[i] = (gae.GICertificate)(c) | |
68 } | |
69 return ret, nil | |
70 } | |
71 func (g giImpl) RequestID() string { | |
72 return appengine.RequestID(g) | |
73 } | |
74 func (g giImpl) ServerSoftware() string { | |
75 return appengine.ServerSoftware() | |
76 } | |
77 func (g giImpl) ServiceAccount() (string, error) { | |
78 return appengine.ServiceAccount(g) | |
79 } | |
80 func (g giImpl) SignBytes(bytes []byte) (keyName string, signature []byte, err e
rror) { | |
81 return appengine.SignBytes(g, bytes) | |
82 } | |
83 func (g giImpl) VersionID() string { | |
84 return appengine.VersionID(g) | |
85 } | |
OLD | NEW |