Skip to content

Commit

Permalink
fix serving static files
Browse files Browse the repository at this point in the history
  • Loading branch information
kubegu committed Aug 31, 2024
1 parent 001c41b commit 1eb89f4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package web
import (
"embed"
"fmt"
"io/fs"
"log"
"net/http"
"strings"
Expand All @@ -15,14 +16,15 @@ import (
//go:embed templates
var htmlTemplates embed.FS

//go:embed static
//go:embed static/*
var staticHtml embed.FS

// Create Mux and setup routes
func InitMux() *http.ServeMux {
mux := http.NewServeMux()
fileSys, _ := fs.Sub(staticHtml, "static")

mux.Handle("/", http.FileServer(http.FS(staticHtml)))
mux.Handle("/", http.FileServer(http.FS(fileSys)))
mux.HandleFunc("/games-index/", gameIndexHandler)
mux.HandleFunc("/movies-search/", movieSearchHandler)
mux.HandleFunc("/games-search/", gameSearchHandler)
Expand Down

0 comments on commit 1eb89f4

Please sign in to comment.