Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 "github.com/luci/luci-go/server/router" | 23 "github.com/luci/luci-go/server/router" |
| 24 "github.com/luci/luci-go/server/templates" | 24 "github.com/luci/luci-go/server/templates" |
| 25 ) | 25 ) |
| 26 | 26 |
| 27 var authconfig *auth.Config | 27 var authconfig *auth.Config |
| 28 | 28 |
| 29 // GetTemplateBundles is used to render HTML templates. It provides base args | 29 // GetTemplateBundles is used to render HTML templates. It provides base args |
| 30 // passed to all templates. | 30 // passed to all templates. |
| 31 func GetTemplateBundle() *templates.Bundle { | 31 func GetTemplateBundle() *templates.Bundle { |
| 32 return &templates.Bundle{ | 32 return &templates.Bundle{ |
| 33 » » Loader: templates.FileSystemLoader("templates"), | 33 » » Loader: templates.FileSystemLoader("../frontend/templat es"), |
|
nodir
2017/05/25 15:23:04
when running a test, cwd is test location, and I a
Ryan Tseng
2017/05/26 18:10:52
Acknowledged. Yeah I think the main value of the
nodir
2017/05/26 18:33:04
yeah, a separate CL is fine.
I don't think we pay
| |
| 34 DebugMode: info.IsDevAppServer, | 34 DebugMode: info.IsDevAppServer, |
| 35 DefaultTemplate: "base", | 35 DefaultTemplate: "base", |
| 36 DefaultArgs: func(c context.Context) (templates.Args, error) { | 36 DefaultArgs: func(c context.Context) (templates.Args, error) { |
| 37 r := getRequest(c) | 37 r := getRequest(c) |
| 38 path := r.URL.Path | 38 path := r.URL.Path |
| 39 loginURL, err := auth.LoginURL(c, path) | 39 loginURL, err := auth.LoginURL(c, path) |
| 40 if err != nil { | 40 if err != nil { |
| 41 return nil, err | 41 return nil, err |
| 42 } | 42 } |
| 43 logoutURL, err := auth.LogoutURL(c, path) | 43 logoutURL, err := auth.LogoutURL(c, path) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 c.Context = WithRequest(c.Context, c.Request) | 114 c.Context = WithRequest(c.Context, c.Request) |
| 115 next(c) | 115 next(c) |
| 116 } | 116 } |
| 117 | 117 |
| 118 func getRequest(c context.Context) *http.Request { | 118 func getRequest(c context.Context) *http.Request { |
| 119 if req, ok := c.Value(&requestKey).(*http.Request); ok { | 119 if req, ok := c.Value(&requestKey).(*http.Request); ok { |
| 120 return req | 120 return req |
| 121 } | 121 } |
| 122 panic("No http.request found in context") | 122 panic("No http.request found in context") |
| 123 } | 123 } |
| OLD | NEW |