preparations for styling: refactor template rendering #1
2 changed files with 5 additions and 7 deletions
|
@ -10,14 +10,14 @@ func (b *BaseHandler) ConfirmRequestHandler(w http.ResponseWriter, req *http.Req
|
||||||
request, err := b.requestRepo.FindBySecret(secret)
|
request, err := b.requestRepo.FindBySecret(secret)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: header 404
|
w.WriteHeader(http.StatusNotFound)
|
||||||
templating.ServeTemplate(w, "requestNotFound", nil)
|
templating.ServeTemplate(w, "requestNotFound", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = b.requestRepo.Execute(request)
|
err = b.requestRepo.Execute(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: write header 500
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
templating.ServeTemplate(w, "executeFailure", err.Error())
|
templating.ServeTemplate(w, "executeFailure", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
8
main.go
8
main.go
|
@ -41,14 +41,12 @@ func main() {
|
||||||
staticHandler := http.FileServer(http.Dir("./static"))
|
staticHandler := http.FileServer(http.Dir("./static"))
|
||||||
// parse templates
|
// parse templates
|
||||||
if err = templating.InitTemplates(); err != nil {
|
if err = templating.InitTemplates(); err != nil {
|
||||||
log.Print(err.Error())
|
log.Fatal(err.Error())
|
||||||
log.Fatal(">>>\nFatal error occurred, aborting program\n<<<\n")
|
|
||||||
}
|
}
|
||||||
// database connection
|
// database connection
|
||||||
db, err := sqldb.Connect(conf)
|
db, err := sqldb.Connect(conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err.Error())
|
log.Fatal(err.Error())
|
||||||
log.Fatal(">>>\nFatal error occurred, aborting program\n<<<\n")
|
|
||||||
}
|
}
|
||||||
// Create repos
|
// Create repos
|
||||||
roomRepo := repositories.NewRoomRepo(db)
|
roomRepo := repositories.NewRoomRepo(db)
|
||||||
|
@ -67,5 +65,5 @@ func main() {
|
||||||
http.Handle("/static/", http.StripPrefix("/static/", staticHandler))
|
http.Handle("/static/", http.StripPrefix("/static/", staticHandler))
|
||||||
|
|
||||||
err = http.ListenAndServe(fmt.Sprintf("%s:%d", conf.Server.ListenAddress, conf.Server.ListenPort), nil)
|
err = http.ListenAndServe(fmt.Sprintf("%s:%d", conf.Server.ListenAddress, conf.Server.ListenPort), nil)
|
||||||
log.Println(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue