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

Side by Side Diff: appengine/ephelper/middleware.go

Issue 1750143003: Remove ephelper and other endpoints code. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 9 months 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/ephelper/errors.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
(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 ephelper
6
7 import (
8 "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
9 gaeauth "github.com/luci/luci-go/appengine/gaeauth/server"
10 "github.com/luci/luci-go/appengine/gaemiddleware"
11 "github.com/luci/luci-go/server/auth"
12 "golang.org/x/net/context"
13 )
14
15 // Middleware is a Context manipulation function that is called when
16 // initializing a ServiceBase.
17 type Middleware func(context.Context) (context.Context, error)
18
19 // TestMode is a no-op middleware layer.
20 var TestMode = []Middleware{}
21
22 // DefaultMiddleware is the default middleware stack for a ServiceBase. It:
23 //
24 // - Installs the AppEngine production service base from
25 // gaemiddleware.WithProd.
26 // - Installs and authenticates the using the Authenticator methods from the
27 // ServiceBase.
28 func DefaultMiddleware(a auth.Authenticator) Middleware {
29 return func(c context.Context) (context.Context, error) {
30 c = gaemiddleware.WithProd(c, endpoints.HTTPRequest(c))
31
32 a := a
33 if a == nil {
34 mi := MethodInfo(c)
35 a = auth.Authenticator{
36 &gaeauth.OAuth2Method{Scopes: mi.Scopes},
37 }
38 }
39 c = auth.SetAuthenticator(c, a)
40 return a.Authenticate(c, endpoints.HTTPRequest(c))
41 }
42 }
OLDNEW
« no previous file with comments | « appengine/ephelper/errors.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698