First release
This commit is contained in:
parent
7cbcab0d48
commit
0df3d16dda
15 changed files with 71 additions and 98 deletions
39
main.go
Normal file
39
main.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"io"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
|
||||
"hugo.mardbrink.se/internal/handlers"
|
||||
)
|
||||
|
||||
type Template struct {
|
||||
template *template.Template
|
||||
}
|
||||
|
||||
func newTemplate() *Template {
|
||||
return &Template{
|
||||
template: template.Must(template.ParseGlob("views/*.html")),
|
||||
}
|
||||
}
|
||||
|
||||
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
|
||||
return t.template.ExecuteTemplate(w, name, data)
|
||||
}
|
||||
|
||||
func main() {
|
||||
e := echo.New()
|
||||
|
||||
e.Renderer = newTemplate()
|
||||
e.Use(middleware.Logger())
|
||||
|
||||
e.Static("/resources", "resources")
|
||||
e.Static("/css", "css")
|
||||
|
||||
handlers.RegisterRoutes(e)
|
||||
|
||||
e.Logger.Fatal(e.Start("0.0.0.0:8080"))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue