Add logger & implement fiber error handling
This commit is contained in:
parent
639652bfeb
commit
5e3814e4fb
8 changed files with 400 additions and 25 deletions
21
main.go
21
main.go
|
|
@ -4,7 +4,6 @@ import (
|
|||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"git.readonly.ch/bouzoure/pop-camarades/controllers"
|
||||
|
|
@ -25,28 +24,21 @@ var embedStatic embed.FS
|
|||
var embedViews embed.FS
|
||||
|
||||
func main() {
|
||||
log := helpers.GetLogger()
|
||||
|
||||
config, err := helpers.GetConfig()
|
||||
if err != nil {
|
||||
// TODO: Handle exception
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = helpers.GetDatabase()
|
||||
if err != nil {
|
||||
// TODO: Handle exception
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
accountCheck, err := helpers.FirstAccountCheck()
|
||||
if err != nil {
|
||||
// TODO: Handle exception
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if !accountCheck {
|
||||
err = helpers.FirstAccountCreate()
|
||||
if err != nil {
|
||||
// TODO: Handle exception
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +63,8 @@ func main() {
|
|||
pongo2.RegisterFilter("time_diff", helpers.TemplTimeDiff)
|
||||
|
||||
app := fiber.New(fiber.Config{
|
||||
Views: engine,
|
||||
Views: engine,
|
||||
ErrorHandler: helpers.FiberErrorHandler,
|
||||
})
|
||||
|
||||
if config.Debug {
|
||||
|
|
@ -205,6 +198,12 @@ func main() {
|
|||
app.Post("/admin/roles/:id<int;min(0)>/edit", controllers.RoleEdit)
|
||||
app.Post("/admin/roles/:id<int;min(0)>/delete", controllers.RoleDelete)
|
||||
|
||||
log.Info(
|
||||
"starting web server",
|
||||
"address", config.App.ListenAddress,
|
||||
"port", config.App.ListenPort,
|
||||
)
|
||||
|
||||
listenAddr := fmt.Sprintf(
|
||||
"%s:%d",
|
||||
config.App.ListenAddress,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue