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:
@@ -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),
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user