Updating movies.go with MovieModel: this struct is the gateway between our app and the database. Adding CRUD methods alongside for the Movie object. Creating models.go: this file holds a Models struct wrapping all of our Models. This way, we are able to use in our application struct in our main.go.

This commit is contained in:
Maxime Delporte
2025-11-06 10:41:12 +01:00
parent 0874a6aac4
commit 1a658d3063
3 changed files with 55 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import (
"database/sql"
"flag"
"fmt"
"greenlight.craftr.fr/internal/data"
"log/slog"
"net/http"
"os"
@@ -40,13 +41,11 @@ type config struct {
}
}
/*
Define an application struct to hold the dependencies for our HTTP handlers, helpers,
and middleware.
*/
// application struct hold the dependencies for our HTTP handlers, helpers, and middleware.
type application struct {
config config
logger *slog.Logger
models data.Models
}
func main() {
@@ -91,6 +90,7 @@ func main() {
app := &application{
config: cfg,
logger: logger,
models: data.NewModels(db),
}
/*