diff options
Diffstat (limited to 'echo/echo_default.go')
-rw-r--r-- | echo/echo_default.go | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/echo/echo_default.go b/echo/echo_default.go index 76f543d..ff3c754 100644 --- a/echo/echo_default.go +++ b/echo/echo_default.go | |||
@@ -22,17 +22,8 @@ import ( | |||
22 | 22 | ||
23 | // Docs: https://echo.labstack.com/guide/ | 23 | // Docs: https://echo.labstack.com/guide/ |
24 | 24 | ||
25 | // TODO: | ||
26 | // - Integrate CSRF | ||
27 | // - Integrate session | ||
28 | |||
29 | const defaultBodySizeLimit = "10M" | 25 | const defaultBodySizeLimit = "10M" |
30 | 26 | ||
31 | var mandatoryTemplates = []string{ | ||
32 | "404.tpl", "40x.tpl", "50x.tpl", | ||
33 | "header.tpl", "footer.tpl", | ||
34 | } | ||
35 | |||
36 | func makeMiddlewareSkipper(c *prometheus.PrometheusConfig) middleware.Skipper { | 27 | func makeMiddlewareSkipper(c *prometheus.PrometheusConfig) middleware.Skipper { |
37 | var path string | 28 | var path string |
38 | 29 | ||
@@ -209,21 +200,17 @@ func (w *EchoWrapper) configureTemplates(c *EchoConfig) error { | |||
209 | templates = c.EmbeddedTemplates | 200 | templates = c.EmbeddedTemplates |
210 | } | 201 | } |
211 | 202 | ||
212 | // Only install template handlers if the path and glob are set | 203 | // Only install template handlers if the path is set |
213 | if templates != nil { | 204 | if templates != nil { |
214 | w.HTTPErrorHandler = ErrorHandler(templates, c.TemplateFunctions) | 205 | tr, err := NewTemplateRenderer(templates, "*.tpl", c.TemplateFunctions, w.Debug) |
215 | |||
216 | tr, err := NewTemplateRenderer(templates, "*.tpl", c.TemplateFunctions) | ||
217 | if err != nil { | 206 | if err != nil { |
218 | return fmt.Errorf("Error loading template renderer: %w", err) | 207 | return fmt.Errorf("Error loading template renderer: %w", err) |
219 | } | 208 | } |
220 | w.Renderer = tr | ||
221 | 209 | ||
222 | for _, t := range mandatoryTemplates { | 210 | w.HTTPErrorHandler = NewDefaultErrorHandler(tr).HandleError |
223 | if !tr.HaveTemplate(w.NewContext(nil, nil), t) { | 211 | w.Renderer = tr |
224 | return fmt.Errorf("Template renderer is missing required template %s", t) | 212 | } else { |
225 | } | 213 | w.HTTPErrorHandler = NewNoHTMLErrorHandler().HandleError |
226 | } | ||
227 | } | 214 | } |
228 | 215 | ||
229 | w.templateFS = templates | 216 | w.templateFS = templates |