handlers/index: refactor to use c.Render
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f80e06078a
commit
468e20da0a
@ -3,7 +3,6 @@ package handlers
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
modtmpl "git.dotya.ml/mirre-mt/pcmt/modules/template"
|
||||
"github.com/labstack/echo-contrib/session"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
@ -23,10 +22,11 @@ func Index() echo.HandlerFunc {
|
||||
return c.Redirect(http.StatusFound, "/home")
|
||||
}
|
||||
|
||||
tpl := modtmpl.Get("index.tmpl")
|
||||
csrf := c.Get("csrf").(string)
|
||||
|
||||
err := tpl.Execute(c.Response().Writer,
|
||||
err := c.Render(
|
||||
http.StatusOK,
|
||||
"index.tmpl",
|
||||
page{
|
||||
AppName: setting.AppName(),
|
||||
AppVer: appver,
|
||||
@ -37,11 +37,16 @@ func Index() echo.HandlerFunc {
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
log.Errorf("error when executing tmpl: '%q'", err)
|
||||
return err
|
||||
c.Logger().Errorf("error: %q", err)
|
||||
|
||||
return renderErrorPage(
|
||||
c,
|
||||
http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError),
|
||||
err.Error(),
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user