From 001c41b273a06588ace4dbb3148eaebcf995f0a7 Mon Sep 17 00:00:00 2001 From: kubegu Date: Sat, 31 Aug 2024 11:54:03 +0200 Subject: [PATCH] embed static html --- main.go | 2 +- web/server.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 9dd0002..697d430 100644 --- a/main.go +++ b/main.go @@ -12,7 +12,7 @@ import ( func main() { port := flag.Int("port", 8080, "Webserver Port") flag.Parse() - + fmt.Printf("listening on port: %d", *port) mux := web.InitMux() log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), mux)) } diff --git a/web/server.go b/web/server.go index 838139c..e029454 100644 --- a/web/server.go +++ b/web/server.go @@ -15,11 +15,14 @@ import ( //go:embed templates var htmlTemplates embed.FS +//go:embed static +var staticHtml embed.FS + // Create Mux and setup routes func InitMux() *http.ServeMux { mux := http.NewServeMux() - mux.Handle("/", http.FileServer(http.Dir("web/static"))) + mux.Handle("/", http.FileServer(http.FS(staticHtml))) mux.HandleFunc("/games-index/", gameIndexHandler) mux.HandleFunc("/movies-search/", movieSearchHandler) mux.HandleFunc("/games-search/", gameSearchHandler)