From 7beb2ae53877f62545e9bc7eaf506f044228b504 Mon Sep 17 00:00:00 2001 From: CronyAkatsuki Date: Wed, 20 Dec 2023 17:36:45 +0100 Subject: [PATCH] Return a struct for index template instead of mapping. --- main.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index f021310..d4f2aa0 100644 --- a/main.go +++ b/main.go @@ -60,15 +60,21 @@ type Template struct { templates *template.Template } +type IndexData struct { + Host string + UploadOnly bool +} + func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error { return t.templates.ExecuteTemplate(w, name, data) } func Index(c echo.Context) error { - return c.Render(http.StatusOK, "index", map[string]interface{}{ - "host": c.Request().Host, - "upload_only": true, - }) + data := IndexData{ + Host: c.Request().Host, + UploadOnly: false, + } + return c.Render(http.StatusOK, "index", data) } func Files(c echo.Context) error {