ch5.3
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"database/sql"
|
||||
"flag"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -13,9 +14,10 @@ import (
|
||||
)
|
||||
|
||||
type application struct {
|
||||
errorLog *log.Logger
|
||||
infoLog *log.Logger
|
||||
snippets *models.SnippetModel
|
||||
errorLog *log.Logger
|
||||
infoLog *log.Logger
|
||||
snippets *models.SnippetModel
|
||||
templateCache map[string]*template.Template
|
||||
}
|
||||
|
||||
type config struct {
|
||||
@@ -40,10 +42,16 @@ func main() {
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
templateCache, err := newTemplateCache()
|
||||
if err != nil {
|
||||
errorLog.Fatal(err)
|
||||
}
|
||||
|
||||
app := &application{
|
||||
errorLog: errorLog,
|
||||
infoLog: infoLog,
|
||||
snippets: &models.SnippetModel{DB: db},
|
||||
errorLog: errorLog,
|
||||
infoLog: infoLog,
|
||||
snippets: &models.SnippetModel{DB: db},
|
||||
templateCache: templateCache,
|
||||
}
|
||||
|
||||
srv := &http.Server{
|
||||
|
||||
Reference in New Issue
Block a user