I'm building a web app and got to a point where I want to add css to my templates. I tried using embed + FileServer to serve my stylesheet but keep getting 404 whenever I tried to GET the file. What am I missing?
package main
import (
"embed"
"github.com/gorilla/mux"
"io/fs"
"log"
"net/http"
)
//go:embed static
var css embed.FS
func main() {
assets, _ := fs.Sub(css, "static")
server := http.FileServer(http.FS(assets))
router := mux.NewRouter()
router.Handle("/static/", http.StripPrefix("/static", server))
err := http.ListenAndServe(":8080", router)
log.Fatal(err)
}