Return a struct for index template instead of mapping.
This commit is contained in:
parent
59104bcb12
commit
7beb2ae538
14
main.go
14
main.go
@ -60,15 +60,21 @@ type Template struct {
|
|||||||
templates *template.Template
|
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 {
|
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
|
||||||
return t.templates.ExecuteTemplate(w, name, data)
|
return t.templates.ExecuteTemplate(w, name, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Index(c echo.Context) error {
|
func Index(c echo.Context) error {
|
||||||
return c.Render(http.StatusOK, "index", map[string]interface{}{
|
data := IndexData{
|
||||||
"host": c.Request().Host,
|
Host: c.Request().Host,
|
||||||
"upload_only": true,
|
UploadOnly: false,
|
||||||
})
|
}
|
||||||
|
return c.Render(http.StatusOK, "index", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Files(c echo.Context) error {
|
func Files(c echo.Context) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user