~yerinalexey/gobin

3b2060b5b9d487be3bd72fee56d7b69f83232e66 — Alexey Yerin 10 months ago 167bac3
feat: configure static root
1 files changed, 6 insertions(+), 1 deletions(-)

M main.go
M main.go => main.go +6 -1
@@ 68,6 68,11 @@ func main() {
		template_root = "./templates"
	}

	static_root, ok := os.LookupEnv("STATIC_ROOT")
	if !ok || template_root == "" {
		static_root = "./static"
	}

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

	r := mux.NewRouter()


@@ 136,7 141,7 @@ func main() {
	})

	// Static files
	fs := http.FileServer(http.Dir("static/"))
	fs := http.FileServer(http.Dir(static_root))
	r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fs))

	/// Not found page