package main

// This file is the one place in your application where all routes are listed.

import (
	"context"
	"crud/api"
	"crud/sqlite"
	"html/template"
	"io/fs"
	"net/http"
)

// addRoutes combines the URL endpoints with the applications's services
// and dependencies and required middleware
func addRoutes(
	ctx context.Context,
	mux *http.ServeMux,
	database *sqlite.Database,
	static fs.FS,
	templ *template.Template,
) {
	mux.Handle("GET /", http.FileServer(http.FS(static)))
	mux.Handle("GET /board", api.Board(ctx, database, templ))
	mux.Handle("GET /edit-record/{id}", api.EditRecord(ctx, database, templ))
	mux.Handle("PATCH /patch-record/{id}", api.PatchRecord(ctx, database, templ))
	mux.Handle("DELETE /delete-record/{id}", api.DeleteRecord(ctx, database, templ))
}
