Added "create list" handler, service + repository
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user