mirror of
https://github.com/ordinary-dev/phoenix
synced 2024-09-19 03:10:29 +05:00
chore: log rendering errors
This commit is contained in:
parent
5aa4396148
commit
c8f8a7feb4
|
@ -5,7 +5,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ordinary-dev/phoenix/database"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func ShowMainPage(w http.ResponseWriter, r *http.Request) {
|
||||
|
@ -38,12 +37,9 @@ func ShowMainPage(w http.ResponseWriter, r *http.Request) {
|
|||
style = "list"
|
||||
}
|
||||
|
||||
err = Render("index.html.tmpl", w, map[string]any{
|
||||
Render("index.html.tmpl", w, map[string]any{
|
||||
"description": "Self-hosted start page.",
|
||||
"groups": groups,
|
||||
"style": style,
|
||||
})
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,22 +4,17 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/ordinary-dev/phoenix/database"
|
||||
"github.com/ordinary-dev/phoenix/jwttoken"
|
||||
)
|
||||
|
||||
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",
|
||||
"description": "Authorization is required to view this page.",
|
||||
"button": "Sign in",
|
||||
"formAction": "/signin",
|
||||
})
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func AuthorizeUser(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
@ -59,12 +59,15 @@ func LoadTemplates() error {
|
|||
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
|
||||
|
||||
if _, ok := data["title"]; !ok {
|
||||
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