Merge pull request #357 from ecornely/master

Get tasks details
This commit is contained in:
Matej Kramny 2017-05-20 15:03:47 +02:00 committed by GitHub
commit 27f51db09c
3 changed files with 19 additions and 0 deletions

View File

@ -923,6 +923,19 @@ paths:
description: Task queued
schema:
$ref: "#/definitions/Task"
/project/{project_id}/tasks/{task_id}:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/task_id"
get:
tags:
- project
summary: Get a single task
responses:
200:
description: Task
schema:
$ref: "#/definitions/Task"
/project/{project_id}/tasks/{task_id}/output:
parameters:
- $ref: '#/parameters/project_id'

View File

@ -99,6 +99,7 @@ func Route() mulekick.Router {
api.Get("/tasks", tasks.GetAll)
api.Post("/tasks", tasks.AddTask)
api.Get("/tasks/{task_id}/output", tasks.GetTaskMiddleware, tasks.GetTaskOutput)
api.Get("/tasks/{task_id}", tasks.GetTaskMiddleware, tasks.GetTask)
api.Delete("/tasks/{task_id}", tasks.GetTaskMiddleware, tasks.RemoveTask)
}(api.Group("/project/{project_id}"))

View File

@ -73,6 +73,11 @@ func GetAll(w http.ResponseWriter, r *http.Request) {
mulekick.WriteJSON(w, http.StatusOK, tasks)
}
func GetTask(w http.ResponseWriter, r *http.Request) {
task := context.Get(r, "task").(db.Task)
mulekick.WriteJSON(w, http.StatusOK, task)
}
func GetTaskMiddleware(w http.ResponseWriter, r *http.Request) {
taskID, err := util.GetIntParam("task_id", w, r)
if err != nil {