Added "create list" handler, service + repository

This commit is contained in:
Robin Dittmar
2026-07-10 14:08:47 +02:00
parent d17eb34c25
commit 85602dbf95
8 changed files with 183 additions and 5 deletions
+13 -1
View File
@@ -1,20 +1,32 @@
package router
import (
"database/sql"
"net/http"
"github.com/robindittmar/dttmr-api/internal/api/handler"
"github.com/robindittmar/dttmr-api/internal/api/middleware"
"github.com/robindittmar/dttmr-api/internal/domain"
"github.com/robindittmar/dttmr-api/internal/repository"
)
type Config struct{}
type Config struct {
Database *sql.DB
}
func NewMux(cfg Config) http.Handler {
listRepo := repository.NewListRepo(cfg.Database)
listService := domain.NewListService(listRepo)
listHandler := handler.ListHandler{ListService: listService}
mux := http.NewServeMux()
mux.HandleFunc("/", handler.DefaultHandler)
mux.HandleFunc("GET /health", handler.HealthHandler)
mux.HandleFunc("POST /lists", listHandler.CreateList)
var httpHandler http.Handler = mux
httpHandler = middleware.WithTelemetry(httpHandler)