Documentation ¶
Index ¶
Constants ¶
View Source
const APIPath = "/todos/"
APIPath is path prefix
Variables ¶
View Source
var EmptyTodo = Todo{}
EmptyTodo is empty todo model
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller handles http request.
func NewController ¶
func NewController(repo Repository) *Controller
NewController return new bindTodo controller instance.
func (Controller) RegisterRoutes ¶
func (controller Controller) RegisterRoutes(router gin.IRouter)
RegisterRoutes register handler routes.
type CreateTodoRequest ¶
type CreateTodoRequest struct { Title string `json:"title" example:"<new title>" binding:"required,min=4,max=100"` Contents string `json:"contents" example:"<new contents>" binding:"required,min=2,max=2048"` }
CreateTodoRequest is request model for creating todo.
type Repository ¶
type Repository interface { CreateTodo(todo Todo) (Todo, error) GetTodos() ([]Todo, error) GetTodoByTodoID(todoID string) (Todo, error) UpdateTodoByTodoID(todoID string, todo Todo) (Todo, error) RemoveTodoByTodoID(todoID string) (Todo, error) }
Repository communications with db connection.
func NewRepository ¶
func NewRepository(dbConn *db.Conn) Repository
NewRepository return new instance.
Click to show internal directories.
Click to hide internal directories.