Add basic webcontent
This commit is contained in:
parent
2dec57d097
commit
f986c2e8e1
5 changed files with 75 additions and 0 deletions
|
@ -1 +1,5 @@
|
|||
<h2>agecem/bottin-ag</h2>
|
||||
|
||||
<h3>StatusCode: {{ .StatusCode }}</h3>
|
||||
<h3>Message: {{ .Message }}</h3>
|
||||
<h3>Error: {{ .Error }}</h3>
|
||||
|
|
|
@ -3,3 +3,32 @@ Package webcontent provides the content to be embedded in the binary executable
|
|||
for the web app
|
||||
*/
|
||||
package webcontent
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io"
|
||||
"text/template"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
//go:embed html/*html
|
||||
var htmlFS embed.FS
|
||||
|
||||
func HTMLFS() embed.FS {
|
||||
return htmlFS
|
||||
}
|
||||
|
||||
type Template struct {
|
||||
templates *template.Template
|
||||
}
|
||||
|
||||
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
|
||||
return t.templates.ExecuteTemplate(w, name, data)
|
||||
}
|
||||
|
||||
func TemplateHTMLFS() *Template {
|
||||
return &Template{
|
||||
templates: template.Must(template.ParseFS(HTMLFS(), "html/*.html")),
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue