go-cook/api/handlers/v1/handler.go

28 lines
484 B
Go
Raw Normal View History

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)
users := v1.Group("/users")
users.POST("/new", h.NewUser)
}