refactor asset with embed tool
This commit is contained in:
26
server/assets_getters_prod.go
Normal file
26
server/assets_getters_prod.go
Normal file
@@ -0,0 +1,26 @@
|
||||
// +build embed
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (_ *Assets) Find(path string) (time.Time, io.ReadSeeker, error) {
|
||||
asset, ok := AssetBytes[path]
|
||||
if !ok {
|
||||
return time.Time{}, nil, ErrAssetNotFound
|
||||
}
|
||||
reader := bytes.NewReader(asset.Bytes)
|
||||
return asset.ModTime, reader, nil
|
||||
}
|
||||
|
||||
func (_ *Assets) FindBytes(path string) (time.Time, []byte, error) {
|
||||
asset, ok := AssetBytes[path]
|
||||
if !ok {
|
||||
return time.Time{}, nil, ErrAssetNotFound
|
||||
}
|
||||
return asset.ModTime, asset.Bytes, nil
|
||||
}
|
||||
Reference in New Issue
Block a user