123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- package main
- import (
- "bytes"
- "compress/gzip"
- "encoding/base64"
- "io/ioutil"
- "net/http"
- "os"
- "path"
- "sync"
- "time"
- )
- type _escLocalFS struct{}
- var _escLocal _escLocalFS
- type _escStaticFS struct{}
- var _escStatic _escStaticFS
- type _escDirectory struct {
- fs http.FileSystem
- name string
- }
- type _escFile struct {
- compressed string
- size int64
- modtime int64
- local string
- isDir bool
- once sync.Once
- data []byte
- name string
- }
- func (_escLocalFS) Open(name string) (http.File, error) {
- f, present := _escData[path.Clean(name)]
- if !present {
- return nil, os.ErrNotExist
- }
- return os.Open(f.local)
- }
- func (_escStaticFS) prepare(name string) (*_escFile, error) {
- f, present := _escData[path.Clean(name)]
- if !present {
- return nil, os.ErrNotExist
- }
- var err error
- f.once.Do(func() {
- f.name = path.Base(name)
- if f.size == 0 {
- return
- }
- var gr *gzip.Reader
- b64 := base64.NewDecoder(base64.StdEncoding, bytes.NewBufferString(f.compressed))
- gr, err = gzip.NewReader(b64)
- if err != nil {
- return
- }
- f.data, err = ioutil.ReadAll(gr)
- })
- if err != nil {
- return nil, err
- }
- return f, nil
- }
- func (fs _escStaticFS) Open(name string) (http.File, error) {
- f, err := fs.prepare(name)
- if err != nil {
- return nil, err
- }
- return f.File()
- }
- func (dir _escDirectory) Open(name string) (http.File, error) {
- return dir.fs.Open(dir.name + name)
- }
- func (f *_escFile) File() (http.File, error) {
- type httpFile struct {
- *bytes.Reader
- *_escFile
- }
- return &httpFile{
- Reader: bytes.NewReader(f.data),
- _escFile: f,
- }, nil
- }
- func (f *_escFile) Close() error {
- return nil
- }
- func (f *_escFile) Readdir(count int) ([]os.FileInfo, error) {
- return nil, nil
- }
- func (f *_escFile) Stat() (os.FileInfo, error) {
- return f, nil
- }
- func (f *_escFile) Name() string {
- return f.name
- }
- func (f *_escFile) Size() int64 {
- return f.size
- }
- func (f *_escFile) Mode() os.FileMode {
- return 0
- }
- func (f *_escFile) ModTime() time.Time {
- return time.Unix(f.modtime, 0)
- }
- func (f *_escFile) IsDir() bool {
- return f.isDir
- }
- func (f *_escFile) Sys() interface{} {
- return f
- }
- // FS returns a http.Filesystem for the embedded assets. If useLocal is true,
- // the filesystem's contents are instead used.
- func FS(useLocal bool) http.FileSystem {
- if useLocal {
- return _escLocal
- }
- return _escStatic
- }
- // Dir returns a http.Filesystem for the embedded assets on a given prefix dir.
- // If useLocal is true, the filesystem's contents are instead used.
- func Dir(useLocal bool, name string) http.FileSystem {
- if useLocal {
- return _escDirectory{fs: _escLocal, name: name}
- }
- return _escDirectory{fs: _escStatic, name: name}
- }
- // FSByte returns the named file from the embedded assets. If useLocal is
- // true, the filesystem's contents are instead used.
- func FSByte(useLocal bool, name string) ([]byte, error) {
- if useLocal {
- f, err := _escLocal.Open(name)
- if err != nil {
- return nil, err
- }
- b, err := ioutil.ReadAll(f)
- f.Close()
- return b, err
- }
- f, err := _escStatic.prepare(name)
- if err != nil {
- return nil, err
- }
- return f.data, nil
- }
- // FSMustByte is the same as FSByte, but panics if name is not present.
- func FSMustByte(useLocal bool, name string) []byte {
- b, err := FSByte(useLocal, name)
- if err != nil {
- panic(err)
- }
- return b
- }
- // FSString is the string version of FSByte.
- func FSString(useLocal bool, name string) (string, error) {
- b, err := FSByte(useLocal, name)
- return string(b), err
- }
- // FSMustString is the string version of FSMustByte.
- func FSMustString(useLocal bool, name string) string {
- return string(FSMustByte(useLocal, name))
- }
- var _escData = map[string]*_escFile{
- "/templates/status.html": {
- local: "templates/status.html",
- size: 3181,
- modtime: 1442049075,
- compressed: `
- H4sIAAAJbogA/7RXTY/bNhA9W7+CEJpbl4rSGKhTWpdskB7qdFO3PfRGiWO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- "/": {
- isDir: true,
- local: "/",
- },
- "/templates": {
- isDir: true,
- local: "/templates",
- },
- }
|