rework template rendering, cache parsed templates
adapt error wrapping principle
This commit is contained in:
parent
7a1448d6f9
commit
f04396809d
21 changed files with 175 additions and 82 deletions
15
main.go
15
main.go
|
@ -11,6 +11,7 @@ import (
|
|||
"officeHours/controllers"
|
||||
"officeHours/repositories"
|
||||
"officeHours/sqldb"
|
||||
"officeHours/templating"
|
||||
"os"
|
||||
)
|
||||
|
||||
|
@ -20,10 +21,6 @@ func main() {
|
|||
log.SetOutput(logwriter)
|
||||
}
|
||||
|
||||
if controllers.TemplateError != nil {
|
||||
log.Fatalf("Error parsing templates: %s", controllers.TemplateError.Error())
|
||||
}
|
||||
|
||||
configFile := flag.String(
|
||||
"config",
|
||||
"config/config.json",
|
||||
|
@ -42,10 +39,16 @@ func main() {
|
|||
|
||||
// serve static files
|
||||
staticHandler := http.FileServer(http.Dir("./static"))
|
||||
|
||||
// parse templates
|
||||
if err = templating.InitTemplates(); err != nil {
|
||||
log.Print(err.Error())
|
||||
log.Fatal(">>>\nFatal error occurred, aborting program\n<<<\n")
|
||||
}
|
||||
// database connection
|
||||
db, err := sqldb.Connect(conf)
|
||||
if err != nil {
|
||||
log.Fatalf(err.Error())
|
||||
log.Print(err.Error())
|
||||
log.Fatal(">>>\nFatal error occurred, aborting program\n<<<\n")
|
||||
}
|
||||
// Create repos
|
||||
roomRepo := repositories.NewRoomRepo(db)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue