~yerinalexey/gobin

167bac3b5fc8fe2e56657a81d1094b88e9916269 — Alexey Yerin 10 months ago 779a0d0
feat: configure template path
1 files changed, 7 insertions(+), 1 deletions(-)

M main.go
M main.go => main.go +7 -1
@@ 22,6 22,7 @@ import (
	"log"
	"net/http"
	"os"
	"path"
	"strconv"

	"github.com/georgysavva/scany/pgxscan"


@@ 62,7 63,12 @@ func main() {
		base_url = "http://localhost:4000"
	}

	tmpl := template.Must(template.ParseGlob("templates/*.html"))
	template_root, ok := os.LookupEnv("TEMPLATE_ROOT")
	if !ok || template_root == "" {
		template_root = "./templates"
	}

	tmpl := template.Must(template.ParseGlob(path.Join(template_root, "*.html")))

	r := mux.NewRouter()
	r.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {