Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: appengine/gaemiddleware/context.go

Issue 1492273003: Remove gaelogger from luci-go (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/gaelogger/logger.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package gaemiddleware 5 package gaemiddleware
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 9
10 "github.com/julienschmidt/httprouter" 10 "github.com/julienschmidt/httprouter"
11 "github.com/luci/gae/impl/prod" 11 "github.com/luci/gae/impl/prod"
12 "github.com/luci/luci-go/appengine/gaeauth/client" 12 "github.com/luci/luci-go/appengine/gaeauth/client"
13 "github.com/luci/luci-go/appengine/gaeauth/server" 13 "github.com/luci/luci-go/appengine/gaeauth/server"
14 "github.com/luci/luci-go/appengine/gaeauth/server/gaesigner" 14 "github.com/luci/luci-go/appengine/gaeauth/server/gaesigner"
15 "github.com/luci/luci-go/appengine/gaelogger"
16 "github.com/luci/luci-go/appengine/gaesecrets" 15 "github.com/luci/luci-go/appengine/gaesecrets"
17 "github.com/luci/luci-go/appengine/gaesettings" 16 "github.com/luci/luci-go/appengine/gaesettings"
18 "github.com/luci/luci-go/server/auth" 17 "github.com/luci/luci-go/server/auth"
19 "github.com/luci/luci-go/server/middleware" 18 "github.com/luci/luci-go/server/middleware"
20 "github.com/luci/luci-go/server/proccache" 19 "github.com/luci/luci-go/server/proccache"
21 "github.com/luci/luci-go/server/settings" 20 "github.com/luci/luci-go/server/settings"
22 "golang.org/x/net/context" 21 "golang.org/x/net/context"
23 ) 22 )
24 23
25 var ( 24 var (
26 // globalProcessCache holds state cached between requests. 25 // globalProcessCache holds state cached between requests.
27 globalProcessCache = &proccache.Cache{} 26 globalProcessCache = &proccache.Cache{}
28 27
29 // globalSettings holds global app settings lazily updated from the data store. 28 // globalSettings holds global app settings lazily updated from the data store.
30 globalSettings = settings.New(gaesettings.Storage{}) 29 globalSettings = settings.New(gaesettings.Storage{})
31 30
32 // globalAuthDBCache knows how to fetch auth.DB from datastore and keep it 31 // globalAuthDBCache knows how to fetch auth.DB from datastore and keep it
33 // in local memory cache. Used in prod contexts only. 32 // in local memory cache. Used in prod contexts only.
34 globalAuthDBCache = auth.NewDBCache(server.GetAuthDB) 33 globalAuthDBCache = auth.NewDBCache(server.GetAuthDB)
35 ) 34 )
36 35
37 // WithProd installs the set of standard production AppEngine services: 36 // WithProd installs the set of standard production AppEngine services:
38 // * github.com/luci/gae/impl/prod (production appengine services) 37 // * github.com/luci/gae/impl/prod (production appengine services)
39 // * github.com/luci/luci-go/appengine/gaelogger (appengine logging service)
40 // * github.com/luci/luci-go/appengine/gaeauth/client (appengine urlfetch tran sport) 38 // * github.com/luci/luci-go/appengine/gaeauth/client (appengine urlfetch tran sport)
41 // * github.com/luci/luci-go/server/proccache (in process memory cache) 39 // * github.com/luci/luci-go/server/proccache (in process memory cache)
42 // * github.com/luci/luci-go/server/settings (global app settings) 40 // * github.com/luci/luci-go/server/settings (global app settings)
43 // * github.com/luci/luci-go/appengine/gaesecrets (access to secret keys in da tastore) 41 // * github.com/luci/luci-go/appengine/gaesecrets (access to secret keys in da tastore)
44 // * github.com/luci/luci-go/appengine/gaeauth/server/gaesigner (RSA signer) 42 // * github.com/luci/luci-go/appengine/gaeauth/server/gaesigner (RSA signer)
45 // * github.com/luci/luci-go/appengine/gaeauth/server/auth (user groups databa se) 43 // * github.com/luci/luci-go/appengine/gaeauth/server/auth (user groups databa se)
46 func WithProd(c context.Context, req *http.Request) context.Context { 44 func WithProd(c context.Context, req *http.Request) context.Context {
47 c = prod.Use(c, req) 45 c = prod.Use(c, req)
48 c = gaelogger.Use(c)
Vadim Sh. 2015/12/04 05:02:40 remove memlogger from gaetesting/middleware.go, Te
iannucci 2015/12/04 20:09:00 good call, done, ptal
49 c = client.UseAnonymousTransport(c) 46 c = client.UseAnonymousTransport(c)
50 c = proccache.Use(c, globalProcessCache) 47 c = proccache.Use(c, globalProcessCache)
51 c = settings.Use(c, globalSettings) 48 c = settings.Use(c, globalSettings)
52 c = gaesecrets.Use(c, nil) 49 c = gaesecrets.Use(c, nil)
53 c = gaesigner.Use(c) 50 c = gaesigner.Use(c)
54 c = auth.UseDB(c, globalAuthDBCache) 51 c = auth.UseDB(c, globalAuthDBCache)
55 return c 52 return c
56 } 53 }
57 54
58 // BaseProd adapts a middleware-style handler to a httprouter.Handle. It 55 // BaseProd adapts a middleware-style handler to a httprouter.Handle. It
59 // installs services using InstallProd, then passes the context. 56 // installs services using InstallProd, then passes the context.
60 func BaseProd(h middleware.Handler) httprouter.Handle { 57 func BaseProd(h middleware.Handler) httprouter.Handle {
61 return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params ) { 58 return func(rw http.ResponseWriter, r *http.Request, p httprouter.Params ) {
62 c := WithProd(context.Background(), r) 59 c := WithProd(context.Background(), r)
63 h(c, rw, r, p) 60 h(c, rw, r, p)
64 } 61 }
65 } 62 }
OLDNEW
« no previous file with comments | « appengine/gaelogger/logger.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698