| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package common | 5 package common |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "net/http" | 8 "net/http" |
| 9 "strings" | 9 "strings" |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 return templates.Args{ | 42 return templates.Args{ |
| 43 "AppVersion": strings.Split(info.VersionID(c),
".")[0], | 43 "AppVersion": strings.Split(info.VersionID(c),
".")[0], |
| 44 "IsAnonymous": auth.CurrentIdentity(c) == identi
ty.AnonymousIdentity, | 44 "IsAnonymous": auth.CurrentIdentity(c) == identi
ty.AnonymousIdentity, |
| 45 "User": auth.CurrentUser(c), | 45 "User": auth.CurrentUser(c), |
| 46 "LoginURL": loginURL, | 46 "LoginURL": loginURL, |
| 47 "LogoutURL": logoutURL, | 47 "LogoutURL": logoutURL, |
| 48 "CurrentTime": clock.Now(c), | 48 "CurrentTime": clock.Now(c), |
| 49 "Analytics": analytics.Snippet(c), | 49 "Analytics": analytics.Snippet(c), |
| 50 "RequestID": info.RequestID(c), | 50 "RequestID": info.RequestID(c), |
| 51 "Request": r, |
| 51 }, nil | 52 }, nil |
| 52 }, | 53 }, |
| 53 FuncMap: funcMap, | 54 FuncMap: funcMap, |
| 54 } | 55 } |
| 55 } | 56 } |
| 56 | 57 |
| 57 // Base returns the basic LUCI appengine middlewares. | 58 // Base returns the basic LUCI appengine middlewares. |
| 58 func Base() router.MiddlewareChain { | 59 func Base() router.MiddlewareChain { |
| 59 return gaemiddleware.BaseProd().Extend( | 60 return gaemiddleware.BaseProd().Extend( |
| 60 auth.Authenticate(server.CookieAuth), | 61 auth.Authenticate(server.CookieAuth), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 79 c.Context = WithRequest(c.Context, c.Request) | 80 c.Context = WithRequest(c.Context, c.Request) |
| 80 next(c) | 81 next(c) |
| 81 } | 82 } |
| 82 | 83 |
| 83 func getRequest(c context.Context) *http.Request { | 84 func getRequest(c context.Context) *http.Request { |
| 84 if req, ok := c.Value(&requestKey).(*http.Request); ok { | 85 if req, ok := c.Value(&requestKey).(*http.Request); ok { |
| 85 return req | 86 return req |
| 86 } | 87 } |
| 87 panic("No http.request found in context") | 88 panic("No http.request found in context") |
| 88 } | 89 } |
| OLD | NEW |