Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateTaskRequest ¶
type CreateTaskRequest struct {
Task *Task `json:"task" binding:"required"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func InitServer ¶
func (Server) RegisterRoutes ¶
func (s Server) RegisterRoutes(t TaskServiceHTTPHandlers)
type Task ¶
type Task struct {
UserId string `json:"userId" example:"johndoe"`
Name string `json:"name" example:"my-task-1"`
Description string `json:"description" example:"description of my-task-1"`
Priority int `json:"priority" example:"1" format:"int64"`
DueAt TimestampTime `json:"dueAt" swaggertype:"primitive,string" example:"2019-10-12T07:20:50.52Z"`
}
Task is a struct with a subset of the fields of domain.Task. It is used when task needs to be provided as an input for task creation. So it excludes auto-generated fields.
type TaskService ¶
type TaskService struct {
Service domain.TaskService
AuthzClient authz.Client
}
func (*TaskService) CreateTask ¶
func (t *TaskService) CreateTask(c *gin.Context)
CreateTask godoc @Summary Creates task @Schemes @Description Creates a new task. @Tags write @Accept json @Produce json @Param task body CreateTaskRequest true "New task" @Success 200 @Router /tasks/ [post] @Param CallerId header string false "the id of the caller" "johndoe" @Security JWT
func (*TaskService) DeleteTask ¶
func (t *TaskService) DeleteTask(c *gin.Context)
DeleteTasks godoc @Summary Deletes task @Schemes @Description Deletes a single task. @Tags write @Accept json @Produce json @Param taskid path int true "Task ID" @Success 200 @Router /tasks/{taskid} [delete] @Param CallerId header string false "the id of the caller" "johndoe" @Security JWT
func (*TaskService) DeleteTasks ¶
func (t *TaskService) DeleteTasks(c *gin.Context)
DeleteTask godoc @Summary Delete all tasks @Schemes @Description Deletes all the tasks. @Tags write @Accept json @Produce json @Success 200 @Router /tasks/ [delete] @Param CallerId header string false "the id of the caller" "johndoe" @Security JWT
func (*TaskService) GetTask ¶
func (t *TaskService) GetTask(c *gin.Context)
GetTask godoc @Summary Get task @Schemes @Description Reads a single task and returns it. @Tags read @Accept json @Produce json @Param taskid path int true "Task ID" @Success 200 {object} domain.Task @Failure 401 {string} string "not found" @Failure default {string} string "unexpected error" @Router /tasks/{taskid} [get] @Param CallerId header string false "the id of the caller" "johndoe" @Security JWT
func (*TaskService) GetTasks ¶
func (t *TaskService) GetTasks(c *gin.Context)
GetTasks godoc @Summary Get all tasks @Schemes @Description Reads and returns all the tasks. @Tags read @Accept json @Produce json @Success 200 {array} domain.Task @Failure default {string} string "unexpected error" @Router /tasks/ [get] @Param CallerId header string false "the id of the caller" "johndoe" @Security JWT
type TaskServiceHTTPHandlers ¶
type TaskServiceHTTPHandlers interface {
GetTask(c *gin.Context)
GetTasks(c *gin.Context)
CreateTask(c *gin.Context)
DeleteTask(c *gin.Context)
DeleteTasks(c *gin.Context)
}
TaskServiceHTTPHandlers defines all the handlers the TaskService needs. It's possible to register routes for a different implementation (like a mock).
type TimestampTime ¶
This section is implemented based on https://github.com/swaggo/swag#use-swaggertype-tag-to-supported-custom-type
func (*TimestampTime) MarshalJSON ¶
func (t *TimestampTime) MarshalJSON() ([]byte, error)
func (*TimestampTime) UnmarshalJSON ¶
func (t *TimestampTime) UnmarshalJSON(bin []byte) error