summaryrefslogtreecommitdiff
path: root/static/static.go
blob: d9dfad319b9f4aaad1844d2cdcba7b3fb5063ee1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package static

import (
	"embed"
	"net/http"
)

//go:embed *.png
//go:embed *.jpg
//go:embed *.ico
//go:embed *.js
//go:embed *.css
var files embed.FS

// MustGetFile returns the contents of a file from static as bytes.
func MustGetFile(name string) []byte {
	b, err := files.ReadFile(name)
	if err != nil {
		panic(err)
	}
	return b
}

// GetFilesystem returns a http.FileSystem for the static files.
func GetFilesystem() http.FileSystem {
	return http.FS(files)
}