Documentation ¶
Overview ¶
Package httpchi implements HTTP handlers for the API.
Index ¶
- func LoggerRequestID(logger zerolog.Logger) func(next http.Handler) http.Handler
- func NewRouter(service Service, logger zerolog.Logger) http.Handler
- func RegisterRoutes(r *chi.Mux, service Service)
- func Run(service Service, logger zerolog.Logger, cfg config.AppCfg)
- type ErrResp
- type MsgResp
- type Service
- func (s Service) CreateTask(w http.ResponseWriter, r *http.Request)
- func (s Service) DeleteTask(w http.ResponseWriter, r *http.Request)
- func (s Service) GetSingleTask(w http.ResponseWriter, r *http.Request)
- func (s Service) ListTasks(w http.ResponseWriter, r *http.Request)
- func (s Service) UpdateTask(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggerRequestID ¶
func RegisterRoutes ¶
func RegisterRoutes(r *chi.Mux, service Service)
Types ¶
type ErrResp ¶
type Service ¶
func NewService ¶
func (Service) CreateTask ¶
func (s Service) CreateTask(w http.ResponseWriter, r *http.Request)
CreateTask creates a new task.
@Summary creates a new task @Description Creates a task with specified fields: title, description, due date, and completion status @Tags Tasks @Accept json @Produce json @Param taskRequest body tasktodo.Request true "Data of the new task" @Success 201 {object} tasktodo.Task "Task successfully created" @Failure 400 {object} ErrResp "Incorrect JSON or invalid date format" @Failure 422 {object} ErrResp "Invalid JSON" @Router /task [post]
func (Service) DeleteTask ¶
func (s Service) DeleteTask(w http.ResponseWriter, r *http.Request)
DeleteTask deletes a task by the specified ID.
@Summary Deletes a task by ID @Description Deletes a task by the specified identifier @Tags Tasks @Accept json @Produce json @Param id path string true "Task ID" @Success 200 {object} MsgResp "Task successfully deleted" @Failure 404 {object} MsgResp "Task not found" @Router /task/{id} [delete]
func (Service) GetSingleTask ¶
func (s Service) GetSingleTask(w http.ResponseWriter, r *http.Request)
GetSingleTask returns a task based on the specified ID.
@Summary Gets a task by ID @Description Retrieves a task based on the provided identifier @Tags Tasks @Accept json @Produce json @Param id path string true "Task ID" @Success 200 {object} tasktodo.Task "Task successfully retrieved" @Failure 404 {object} MsgResp "Task not found" @Router /task/{id} [get]
func (Service) ListTasks ¶
func (s Service) ListTasks(w http.ResponseWriter, r *http.Request)
ListTasks returns a list of tasks considering request parameters.
@Summary Returns a list of tasks with filtering and pagination @Description Retrieves a list of tasks based on status, date, and page for pagination @Tags Tasks @Accept json @Produce json @Param status query string false "Task completion status (true/false)" @Param date query string false "Task date (format: YYYY-MM-DD)" @Param page query string false "Page number for pagination" @Success 200 {object} []tasktodo.Task "List of tasks" @Failure 400 {object} ErrResp "Invalid request parameters" @Failure 404 {object} MsgResp "Tasks not found" @Router /tasks [get]
func (Service) UpdateTask ¶
func (s Service) UpdateTask(w http.ResponseWriter, r *http.Request)
UpdateTask updates a task by the specified ID.
@Summary Updates a task by ID @Description Updates a task by the specified identifier @Tags Tasks @Accept json @Produce json @Param id path string true "Task ID" @Param taskUpd body tasktodo.Request true "Data for updating the task" @Success 200 {object} tasktodo.Task "Task successfully updated" @Failure 400 {object} ErrResp "Incorrect JSON or invalid date format" @Failure 404 {object} MsgResp "Task not found" @Failure 422 {object} ErrResp "Invalid JSON" @Router /task/{id} [put]
Click to show internal directories.
Click to hide internal directories.