2024-03-20 17:54:23 -07:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"go-cook/api/repositories"
|
|
|
|
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Handler struct {
|
|
|
|
userRepo repositories.UserRepository
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHandler(conn *sql.DB) *Handler {
|
|
|
|
return &Handler{
|
|
|
|
userRepo: repositories.NewUserRepository(conn),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handler) Register(v1 *echo.Group) {
|
|
|
|
demo := v1.Group("/demo")
|
|
|
|
demo.GET("/hello", h.DemoHello)
|
|
|
|
demo.GET("/hello/:who", h.HelloWho)
|
2024-03-23 08:26:49 -07:00
|
|
|
demo.GET("/hello/body", h.HelloBody)
|
2024-03-20 17:54:23 -07:00
|
|
|
|
|
|
|
users := v1.Group("/users")
|
|
|
|
users.POST("/new", h.NewUser)
|
|
|
|
}
|