aboutsummaryrefslogtreecommitdiffstats
path: root/template.go
diff options
context:
space:
mode:
authorLibravatarLibravatar Simon Ser <[email protected]> 2019-12-02 15:31:00 +0100
committerLibravatarLibravatar Simon Ser <[email protected]> 2019-12-02 15:31:00 +0100
commita1a067e6de1679d0a3a1503e93bb672432990cd4 (patch)
treed56234ae02077a0bf85bd549ca90301a54d581d4 /template.go
downloadalps-a1a067e6de1679d0a3a1503e93bb672432990cd4.tar.gz
alps-a1a067e6de1679d0a3a1503e93bb672432990cd4.tar.bz2
alps-a1a067e6de1679d0a3a1503e93bb672432990cd4.zip
Add HTTP server boilerplate
Diffstat (limited to 'template.go')
-rw-r--r--template.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/template.go b/template.go
new file mode 100644
index 0000000..fae5c7f
--- /dev/null
+++ b/template.go
@@ -0,0 +1,24 @@
+package koushin
+
+import (
+ "fmt"
+ "html/template"
+ "io"
+
+ "github.com/labstack/echo/v4"
+)
+
+type tmpl struct {
+ t *template.Template
+}
+
+var _ = fmt.Printf
+
+func (t *tmpl) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
+ return t.t.ExecuteTemplate(w, name, data)
+}
+
+func loadTemplates() (*tmpl, error) {
+ t, err := template.New("drmdb").ParseGlob("public/*.html")
+ return &tmpl{t}, err
+}