mirror of
https://github.com/ordinary-dev/phoenix
synced 2024-09-19 19:30:28 +05:00
chore: log rendering errors
This commit is contained in:
parent
5aa4396148
commit
c8f8a7feb4
|
@ -5,7 +5,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ordinary-dev/phoenix/database"
|
"github.com/ordinary-dev/phoenix/database"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func ShowMainPage(w http.ResponseWriter, r *http.Request) {
|
func ShowMainPage(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -38,12 +37,9 @@ func ShowMainPage(w http.ResponseWriter, r *http.Request) {
|
||||||
style = "list"
|
style = "list"
|
||||||
}
|
}
|
||||||
|
|
||||||
err = Render("index.html.tmpl", w, map[string]any{
|
Render("index.html.tmpl", w, map[string]any{
|
||||||
"description": "Self-hosted start page.",
|
"description": "Self-hosted start page.",
|
||||||
"groups": groups,
|
"groups": groups,
|
||||||
"style": style,
|
"style": style,
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
log.Error(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,22 +4,17 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/ordinary-dev/phoenix/database"
|
"github.com/ordinary-dev/phoenix/database"
|
||||||
"github.com/ordinary-dev/phoenix/jwttoken"
|
"github.com/ordinary-dev/phoenix/jwttoken"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ShowSignInForm(w http.ResponseWriter, _ *http.Request) {
|
func ShowSignInForm(w http.ResponseWriter, _ *http.Request) {
|
||||||
err := Render("auth.html.tmpl", w, map[string]any{
|
Render("auth.html.tmpl", w, map[string]any{
|
||||||
"title": "Sign in",
|
"title": "Sign in",
|
||||||
"description": "Authorization is required to view this page.",
|
"description": "Authorization is required to view this page.",
|
||||||
"button": "Sign in",
|
"button": "Sign in",
|
||||||
"formAction": "/signin",
|
"formAction": "/signin",
|
||||||
})
|
})
|
||||||
if err != nil {
|
|
||||||
log.Error(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func AuthorizeUser(w http.ResponseWriter, r *http.Request) {
|
func AuthorizeUser(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -59,12 +59,15 @@ func LoadTemplates() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func Render(template string, wr io.Writer, data map[string]any) error {
|
func Render(template string, wr io.Writer, data map[string]any) {
|
||||||
data["fontFamily"] = config.Cfg.FontFamily
|
data["fontFamily"] = config.Cfg.FontFamily
|
||||||
|
|
||||||
if _, ok := data["title"]; !ok {
|
if _, ok := data["title"]; !ok {
|
||||||
data["title"] = config.Cfg.Title
|
data["title"] = config.Cfg.Title
|
||||||
}
|
}
|
||||||
|
|
||||||
return templates[template].Execute(wr, data)
|
err := templates[template].Execute(wr, data)
|
||||||
|
if err != nil {
|
||||||
|
log.WithField("template", template).Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue