(c *gin.Context)
| 76 | } |
| 77 | |
| 78 | func getTask(c *gin.Context) { |
| 79 | r := struct { |
| 80 | ID int64 `json:"id" form:"id" uri:"id" binding:"required"` |
| 81 | }{} |
| 82 | |
| 83 | _ = c.ShouldBindUri(&r) |
| 84 | |
| 85 | if err := c.ShouldBind(&r); err != nil { |
| 86 | abortWithError(c, http.StatusBadRequest, err) |
| 87 | return |
| 88 | } |
| 89 | |
| 90 | developer := getDeveloperID(c) |
| 91 | task, err := model.GetTask(model.GetDB(c), developer, r.ID) |
| 92 | if err != nil { |
| 93 | _ = c.Error(err) |
| 94 | abortWithError(c, http.StatusForbidden, ErrGetTaskDetailFailed) |
| 95 | return |
| 96 | } |
| 97 | |
| 98 | responseWithData(c, http.StatusOK, gin.H{ |
| 99 | "task": func(t *model.Task) gin.H { |
| 100 | return gin.H{ |
| 101 | "id": t.ID, |
| 102 | "type": t.Type.String(), |
| 103 | "state": t.State.String(), |
| 104 | "args": t.Args, |
| 105 | "result": t.Result, |
| 106 | "created": formatUnixTime(t.Created), |
| 107 | "updated": formatUnixTime(t.Updated), |
| 108 | "finished": formatUnixTime(t.Finished), |
| 109 | } |
| 110 | }(task), |
| 111 | }) |
| 112 | } |
| 113 | |
| 114 | func cancelTask(c *gin.Context) { |
| 115 | r := struct { |
nothing calls this directly
no test coverage detected