package handler import ( "net/http" "code.nochebuena.dev/go/httputil" "code.nochebuena.dev/go/valid" "code.nochebuena.dev/go/todo-api/internal/domain" "code.nochebuena.dev/go/todo-api/internal/service" ) // TodoHandler wires HTTP requests to the TodoService. type TodoHandler struct { svc service.TodoService v valid.Validator } // NewTodoHandler returns a TodoHandler. func NewTodoHandler(svc service.TodoService, v valid.Validator) *TodoHandler { return &TodoHandler{svc: svc, v: v} } // FindAll handles GET /todos — returns all todos as JSON. func (h *TodoHandler) FindAll(w http.ResponseWriter, r *http.Request) { httputil.HandleNoBody[[]domain.Todo](h.svc.FindAll).ServeHTTP(w, r) } // Create handles POST /todos — creates a new todo from the JSON body. func (h *TodoHandler) Create(w http.ResponseWriter, r *http.Request) { httputil.Handle[service.CreateTodoRequest, domain.Todo](h.v, h.svc.Create).ServeHTTP(w, r) }