feat: assetsFS for serving images and media

This commit is contained in:
HeshamTB 2023-09-13 11:26:23 +03:00
parent b134705abc
commit 61fa4fe192
3 changed files with 7 additions and 0 deletions

BIN
assets/images/downloads.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -7,3 +7,7 @@ var TemplatesFS embed.FS
//go:embed static/css/*
var PublicFS embed.FS
//go:embed assets/*
var AssetsFS embed.FS

View File

@ -113,12 +113,15 @@ func init() {
log.Println("[ init ] Starting...")
templates = template.Must(template.ParseFS(TemplatesFS , "templates/*.html"))
log.Println("[ init ] Templates Loaded")
}
func main() {
handler := http.NewServeMux()
handler.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(PublicFS))))
handler.Handle("/assets/", http.FileServer(http.FS(AssetsFS)))
handler.HandleFunc(
"/download",