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 "github.com/luci/gae" | |
11 "golang.org/x/net/context" | |
12 "google.golang.org/appengine" | |
13 ) | |
14 | |
15 // useGI adds a gae.GlobalInfo implementation to context, accessible | |
16 // by gae.GetGI(c) | |
17 func useGI(c context.Context) context.Context { | |
18 return gae.SetGIFactory(c, func(ci context.Context) gae.GlobalInfo { | |
19 return giImpl{ci} | |
20 }) | |
21 } | |
22 | |
23 type giImpl struct{ context.Context } | |
24 | |
25 func (g giImpl) AccessToken(scopes ...string) (token string, expiry time.Time, e
rr error) { | |
26 return appengine.AccessToken(g, scopes...) | |
27 } | |
28 func (g giImpl) AppID() string { | |
29 return appengine.AppID(g) | |
30 } | |
31 func (g giImpl) Datacenter() string { | |
32 return appengine.Datacenter(g) | |
33 } | |
34 func (g giImpl) DefaultVersionHostname() string { | |
35 return appengine.DefaultVersionHostname(g) | |
36 } | |
37 func (g giImpl) InstanceID() string { | |
38 return appengine.InstanceID() | |
39 } | |
40 func (g giImpl) IsDevAppServer() bool { | |
41 return appengine.IsDevAppServer() | |
42 } | |
43 func (g giImpl) IsOverQuota(err error) bool { | |
44 return appengine.IsOverQuota(err) | |
45 } | |
46 func (g giImpl) IsTimeoutError(err error) bool { | |
47 return appengine.IsTimeoutError(err) | |
48 } | |
49 func (g giImpl) ModuleHostname(module, version, instance string) (string, error)
{ | |
50 return appengine.ModuleHostname(g, module, version, instance) | |
51 } | |
52 func (g giImpl) ModuleName() (name string) { | |
53 return appengine.ModuleName(g) | |
54 } | |
55 func (g giImpl) Namespace(namespace string) (context.Context, error) { | |
56 return appengine.Namespace(g, namespace) | |
57 } | |
58 func (g giImpl) PublicCertificates() ([]gae.GICertificate, error) { | |
59 certs, err := appengine.PublicCertificates(g) | |
60 if err != nil { | |
61 return nil, err | |
62 } | |
63 ret := make([]gae.GICertificate, len(certs)) | |
64 for i, c := range certs { | |
65 ret[i] = (gae.GICertificate)(c) | |
66 } | |
67 return ret, nil | |
68 } | |
69 func (g giImpl) RequestID() string { | |
70 return appengine.RequestID(g) | |
71 } | |
72 func (g giImpl) ServerSoftware() string { | |
73 return appengine.ServerSoftware() | |
74 } | |
75 func (g giImpl) ServiceAccount() (string, error) { | |
76 return appengine.ServiceAccount(g) | |
77 } | |
78 func (g giImpl) SignBytes(bytes []byte) (keyName string, signature []byte, err e
rror) { | |
79 return appengine.SignBytes(g, bytes) | |
80 } | |
81 func (g giImpl) VersionID() string { | |
82 return appengine.VersionID(g) | |
83 } | |
OLD | NEW |