diff options
| author | gabek <gabek@noreply@mills.io> | 2022-08-30 01:17:08 +0000 |
|---|---|---|
| committer | James Mills <james@mills.io> | 2022-08-30 01:17:08 +0000 |
| commit | 29f278459156f7bd9aec225ed78706d18e001c56 (patch) | |
| tree | 1a1645c079e372ba96836fd63501a73b9e78b20b /static | |
| parent | 199aaa171f552719a7ac4c6539b921827de22d96 (diff) | |
Replace rice box with go embed (#25)
Reviewed-on: https://git.mills.io/prologic/tube/pulls/25
Co-authored-by: gabek <gabek@noreply@mills.io>
Co-committed-by: gabek <gabek@noreply@mills.io>
Diffstat (limited to 'static')
| -rw-r--r-- | static/static.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/static/static.go b/static/static.go new file mode 100644 index 0000000..d9dfad3 --- /dev/null +++ b/static/static.go @@ -0,0 +1,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) +} |
