| Index: appengine/cmd/cron/ui/job.go
|
| diff --git a/appengine/cmd/cron/ui/job.go b/appengine/cmd/cron/ui/job.go
|
| index b6735f093e323acd42cf21d57041cd39fb6853e6..500fbb3c262393034433afa8cc50956ea7757b78 100644
|
| --- a/appengine/cmd/cron/ui/job.go
|
| +++ b/appengine/cmd/cron/ui/job.go
|
| @@ -4,30 +4,30 @@
|
|
|
| package ui
|
|
|
| import (
|
| "crypto/sha1"
|
| "encoding/base64"
|
| "fmt"
|
| "net/http"
|
| "time"
|
|
|
| - "github.com/julienschmidt/httprouter"
|
| - "golang.org/x/net/context"
|
| -
|
| "github.com/luci/gae/service/memcache"
|
| "github.com/luci/luci-go/common/clock"
|
| "github.com/luci/luci-go/server/auth"
|
| + "github.com/luci/luci-go/server/router"
|
| "github.com/luci/luci-go/server/templates"
|
| )
|
|
|
| -func jobPage(c context.Context, w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
| +func jobPage(ctx *router.Context) {
|
| + c, w, r, p := ctx.Context, ctx.Writer, ctx.Request, ctx.Params
|
| +
|
| projectID := p.ByName("ProjectID")
|
| jobID := p.ByName("JobID")
|
| cursor := r.URL.Query().Get("c")
|
|
|
| // Grab the job from the datastore.
|
| job, err := config(c).Engine.GetCronJob(c, projectID+"/"+jobID)
|
| if err != nil {
|
| panic(err)
|
| }
|
| if job == nil {
|
| @@ -76,21 +76,23 @@ func jobPage(c context.Context, w http.ResponseWriter, r *http.Request, p httpro
|
| "Job": makeCronJob(job, now),
|
| "Invocations": convertToInvocations(job.ProjectID, job.JobID, invs, now),
|
| "PrevCursor": prevCursor,
|
| "NextCursor": nextCursor,
|
| })
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| // Actions.
|
|
|
| -func runJobAction(c context.Context, w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
| +func runJobAction(ctx *router.Context) {
|
| + c, w, r, p := ctx.Context, ctx.Writer, ctx.Request, ctx.Params
|
| +
|
| projectID := p.ByName("ProjectID")
|
| jobID := p.ByName("JobID")
|
| if !isJobOwner(c, projectID, jobID) {
|
| http.Error(w, "Forbidden", 403)
|
| return
|
| }
|
|
|
| // genericReply renders "we did something (or we failed to do something)"
|
| // page, shown on error or if invocation is starting for too long.
|
| genericReply := func(err error) {
|
| @@ -133,36 +135,36 @@ func runJobAction(c context.Context, w http.ResponseWriter, r *http.Request, p h
|
| }
|
| }
|
|
|
| if invID != 0 {
|
| http.Redirect(w, r, fmt.Sprintf("/jobs/%s/%s/%d", projectID, jobID, invID), http.StatusFound)
|
| } else {
|
| genericReply(nil) // deadline
|
| }
|
| }
|
|
|
| -func pauseJobAction(c context.Context, w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
| - handleJobAction(c, w, r, p, func(jobID string) error {
|
| - who := auth.CurrentIdentity(c)
|
| - return config(c).Engine.PauseJob(c, jobID, who)
|
| +func pauseJobAction(c *router.Context) {
|
| + handleJobAction(c, func(jobID string) error {
|
| + who := auth.CurrentIdentity(c.Context)
|
| + return config(c.Context).Engine.PauseJob(c.Context, jobID, who)
|
| })
|
| }
|
|
|
| -func resumeJobAction(c context.Context, w http.ResponseWriter, r *http.Request, p httprouter.Params) {
|
| - handleJobAction(c, w, r, p, func(jobID string) error {
|
| - who := auth.CurrentIdentity(c)
|
| - return config(c).Engine.ResumeJob(c, jobID, who)
|
| +func resumeJobAction(c *router.Context) {
|
| + handleJobAction(c, func(jobID string) error {
|
| + who := auth.CurrentIdentity(c.Context)
|
| + return config(c.Context).Engine.ResumeJob(c.Context, jobID, who)
|
| })
|
| }
|
|
|
| -func handleJobAction(c context.Context, w http.ResponseWriter, r *http.Request, p httprouter.Params, cb func(string) error) {
|
| - projectID := p.ByName("ProjectID")
|
| - jobID := p.ByName("JobID")
|
| - if !isJobOwner(c, projectID, jobID) {
|
| - http.Error(w, "Forbidden", 403)
|
| +func handleJobAction(c *router.Context, cb func(string) error) {
|
| + projectID := c.Params.ByName("ProjectID")
|
| + jobID := c.Params.ByName("JobID")
|
| + if !isJobOwner(c.Context, projectID, jobID) {
|
| + http.Error(c.Writer, "Forbidden", 403)
|
| return
|
| }
|
| if err := cb(projectID + "/" + jobID); err != nil {
|
| panic(err)
|
| }
|
| - http.Redirect(w, r, fmt.Sprintf("/jobs/%s/%s", projectID, jobID), http.StatusFound)
|
| + http.Redirect(c.Writer, c.Request, fmt.Sprintf("/jobs/%s/%s", projectID, jobID), http.StatusFound)
|
| }
|
|
|