2025-11-09 11:34:11 +01:00

31 lines
914 B
Go

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 /delete-record/{id}", api.DeleteRecord(ctx, database, templ))
// mux.Handle("GET /count", api.ProductCount(database))
// mux.Handle("GET /nutriments/{page}", api.DataNutriments(database, templ))
// mux.Handle("GET /products/{page}", api.DataProducts(database, templ))
// mux.Handle("GET /brandowner/{page}", api.DataBrandOwner(database, templ))
}