Skip to content

Commit

Permalink
embed static html
Browse files Browse the repository at this point in the history
  • Loading branch information
kubegu committed Aug 31, 2024
1 parent 7f3c570 commit 001c41b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
5 changes: 4 additions & 1 deletion web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 001c41b

Please sign in to comment.