Skip to content

Commit

Permalink
templating worky
Browse files Browse the repository at this point in the history
  • Loading branch information
radiosilence committed Nov 24, 2023
1 parent 66c3b79 commit 456790a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"encoding/json"
"fmt"
"io"
"net/http"
Expand All @@ -17,7 +18,8 @@ type Template struct {
}

type TemplateData struct {
Env map[string]string `json:"env"`
Env map[string]string `json:"env"`
Json string `json:"json"`
}

func (t *Template) Render(w io.Writer, name string, data any, c echo.Context) error {
Expand All @@ -42,8 +44,13 @@ func getAppEnv() map[string]string {
var appEnv = getAppEnv()

func Index(c echo.Context) error {
jsonString, err := json.Marshal(appEnv)
if err != nil {
return err
}
return c.Render(http.StatusOK, "index.html", &TemplateData{
Env: appEnv,
Env: appEnv,
Json: string(jsonString),
})
}

Expand Down

0 comments on commit 456790a

Please sign in to comment.