| 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 ui implements request handlers that serve user facing HTML pages. | 5 // Package ui implements request handlers that serve user facing HTML pages. |
| 6 package ui | 6 package ui |
| 7 | 7 |
| 8 import ( | 8 import ( |
| 9 "strings" | 9 "strings" |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 c.Context = context.WithValue(c.Context, configContextKey(0), &c
fg) | 37 c.Context = context.WithValue(c.Context, configContextKey(0), &c
fg) |
| 38 next(c) | 38 next(c) |
| 39 }) | 39 }) |
| 40 m = m.Extend( | 40 m = m.Extend( |
| 41 templates.WithTemplates(tmpl), | 41 templates.WithTemplates(tmpl), |
| 42 auth.Authenticate(server.UsersAPIAuthMethod{}), | 42 auth.Authenticate(server.UsersAPIAuthMethod{}), |
| 43 ) | 43 ) |
| 44 | 44 |
| 45 r.GET("/", m, indexPage) | 45 r.GET("/", m, indexPage) |
| 46 r.GET("/jobs/:ProjectID", m, projectPage) | 46 r.GET("/jobs/:ProjectID", m, projectPage) |
| 47 » r.GET("/jobs/:ProjectID/:JobID", m, jobPage) | 47 » r.GET("/jobs/:ProjectID/:JobName", m, jobPage) |
| 48 » r.GET("/jobs/:ProjectID/:JobID/:InvID", m, invocationPage) | 48 » r.GET("/jobs/:ProjectID/:JobName/:InvID", m, invocationPage) |
| 49 | 49 |
| 50 // All POST forms must be protected with XSRF token. | 50 // All POST forms must be protected with XSRF token. |
| 51 mxsrf := m.Extend(xsrf.WithTokenCheck) | 51 mxsrf := m.Extend(xsrf.WithTokenCheck) |
| 52 » r.POST("/actions/runJob/:ProjectID/:JobID", mxsrf, runJobAction) | 52 » r.POST("/actions/runJob/:ProjectID/:JobName", mxsrf, runJobAction) |
| 53 » r.POST("/actions/pauseJob/:ProjectID/:JobID", mxsrf, pauseJobAction) | 53 » r.POST("/actions/pauseJob/:ProjectID/:JobName", mxsrf, pauseJobAction) |
| 54 » r.POST("/actions/resumeJob/:ProjectID/:JobID", mxsrf, resumeJobAction) | 54 » r.POST("/actions/resumeJob/:ProjectID/:JobName", mxsrf, resumeJobAction) |
| 55 » r.POST("/actions/abortJob/:ProjectID/:JobID", mxsrf, abortJobAction) | 55 » r.POST("/actions/abortJob/:ProjectID/:JobName", mxsrf, abortJobAction) |
| 56 » r.POST("/actions/abortInvocation/:ProjectID/:JobID/:InvID", mxsrf, abort
InvocationAction) | 56 » r.POST("/actions/abortInvocation/:ProjectID/:JobName/:InvID", mxsrf, abo
rtInvocationAction) |
| 57 } | 57 } |
| 58 | 58 |
| 59 type configContextKey int | 59 type configContextKey int |
| 60 | 60 |
| 61 // config returns Config passed to InstallHandlers. | 61 // config returns Config passed to InstallHandlers. |
| 62 func config(c context.Context) *Config { | 62 func config(c context.Context) *Config { |
| 63 cfg, _ := c.Value(configContextKey(0)).(*Config) | 63 cfg, _ := c.Value(configContextKey(0)).(*Config) |
| 64 if cfg == nil { | 64 if cfg == nil { |
| 65 panic("impossible, configContextKey is not set") | 65 panic("impossible, configContextKey is not set") |
| 66 } | 66 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 92 "AppVersion": strings.Split(info.VersionID(c),
".")[0], | 92 "AppVersion": strings.Split(info.VersionID(c),
".")[0], |
| 93 "IsAnonymous": auth.CurrentIdentity(c) == "anony
mous:anonymous", | 93 "IsAnonymous": auth.CurrentIdentity(c) == "anony
mous:anonymous", |
| 94 "User": auth.CurrentUser(c), | 94 "User": auth.CurrentUser(c), |
| 95 "LoginURL": loginURL, | 95 "LoginURL": loginURL, |
| 96 "LogoutURL": logoutURL, | 96 "LogoutURL": logoutURL, |
| 97 "XsrfToken": token, | 97 "XsrfToken": token, |
| 98 }, nil | 98 }, nil |
| 99 }, | 99 }, |
| 100 } | 100 } |
| 101 } | 101 } |
| OLD | NEW |