27 lines
428 B
Go
27 lines
428 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 hashfs.FileServer(staticSys)
|
|
}
|
|
|
|
func StaticPath(path string) string {
|
|
return "/" + staticSys.HashName(path)
|
|
}
|