| 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 settings | 5 package settings |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "io" | 9 "io" |
| 10 "net/http" | 10 "net/http" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 panic(fmt.Errorf("Error: Could not load template %s from theme %s", name
, theme)) | 148 panic(fmt.Errorf("Error: Could not load template %s from theme %s", name
, theme)) |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Base returns the basic luci appengine middlewares. | 151 // Base returns the basic luci appengine middlewares. |
| 152 func Base() router.MiddlewareChain { | 152 func Base() router.MiddlewareChain { |
| 153 methods := auth.Authenticator{ | 153 methods := auth.Authenticator{ |
| 154 &server.OAuth2Method{Scopes: []string{server.EmailScope}}, | 154 &server.OAuth2Method{Scopes: []string{server.EmailScope}}, |
| 155 server.CookieAuth, | 155 server.CookieAuth, |
| 156 &server.InboundAppIDAuthMethod{}, | 156 &server.InboundAppIDAuthMethod{}, |
| 157 } | 157 } |
| 158 » m := gaemiddleware.BaseProd().Extend(auth.Use(methods)) | 158 » m := gaemiddleware.BaseProd().Extend(auth.Use(methods), auth.Authenticat
e) |
| 159 for _, nb := range GetTemplateBundles() { | 159 for _, nb := range GetTemplateBundles() { |
| 160 m = m.Extend(withNamedBundle(nb)) | 160 m = m.Extend(withNamedBundle(nb)) |
| 161 } | 161 } |
| 162 return m | 162 return m |
| 163 } | 163 } |
| 164 | 164 |
| 165 // Wrap adapts a ThemedHandler into a router.Handler. Of note, the | 165 // Wrap adapts a ThemedHandler into a router.Handler. Of note, the |
| 166 // Render functions' interface into rendering is purely through a single | 166 // Render functions' interface into rendering is purely through a single |
| 167 // templates.Args value which gets rendered here, while the http.ResponseWriter | 167 // templates.Args value which gets rendered here, while the http.ResponseWriter |
| 168 // is stripped out. | 168 // is stripped out. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 184 http.Error(c.Writer, err.Error(), http.StatusInt
ernalServerError) | 184 http.Error(c.Writer, err.Error(), http.StatusInt
ernalServerError) |
| 185 } | 185 } |
| 186 return | 186 return |
| 187 } | 187 } |
| 188 | 188 |
| 189 // Render the stuff. | 189 // Render the stuff. |
| 190 name := fmt.Sprintf("pages/%s", template) | 190 name := fmt.Sprintf("pages/%s", template) |
| 191 themedMustRender(c.Context, c.Writer, theme.Name, name, *args) | 191 themedMustRender(c.Context, c.Writer, theme.Name, name, *args) |
| 192 } | 192 } |
| 193 } | 193 } |
| OLD | NEW |