Combine error templates.
This commit is contained in:
parent
3a9f0d1879
commit
58e75cf7a6
8 changed files with 24 additions and 18 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
|
|
@ -26,8 +25,7 @@ func (e *Error) Get(err error, c echo.Context) {
|
|||
p := NewPage(c)
|
||||
p.Layout = "main"
|
||||
p.Title = http.StatusText(code)
|
||||
// TODO: fallback if there is no error template
|
||||
p.Name = fmt.Sprintf("errors/%d", code)
|
||||
p.Name = "error"
|
||||
p.StatusCode = code
|
||||
|
||||
if err = e.RenderPage(c, p); err != nil {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ type Page struct {
|
|||
MaxAge time.Duration
|
||||
Tags []string
|
||||
}
|
||||
RequestID string
|
||||
}
|
||||
|
||||
func NewPage(c echo.Context) Page {
|
||||
|
|
@ -51,6 +52,7 @@ func NewPage(c echo.Context) Page {
|
|||
StatusCode: http.StatusOK,
|
||||
Pager: pager.NewPager(c, DefaultItemsPerPage),
|
||||
Headers: make(map[string]string),
|
||||
RequestID: c.Response().Header().Get(echo.HeaderXRequestID),
|
||||
}
|
||||
|
||||
p.IsHome = p.Path == "/"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue