27 lines
465 B
Go
27 lines
465 B
Go
//go:build !dev
|
|
|
|
package assets
|
|
|
|
import (
|
|
"embed"
|
|
"net/http"
|
|
|
|
"github.com/benbjohnson/hashfs"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
var (
|
|
//go:embed css js
|
|
staticFiles embed.FS
|
|
staticSys = hashfs.NewFS(staticFiles)
|
|
)
|
|
|
|
func Handler() http.Handler {
|
|
log.Debug().Msg("static assets are embedded with hashfs")
|
|
return http.StripPrefix("/assets/", hashfs.FileServer(staticSys))
|
|
}
|
|
|
|
func StaticPath(path string) string {
|
|
return "/assets/" + staticSys.HashName(path)
|
|
}
|