Documentation ¶
Index ¶
- func NewAssets(prefix string, fsys fs.FS, opts ...AssetsOption) fs.FS
- func RelativeFS(prefix string, fs fs.FS) fs.FS
- func ServeFile(wr io.Writer, fsys fs.FS, name string) (int, error)
- type AssetsFlags
- type AssetsOption
- func EnableDebugging() AssetsOption
- func EnableLogging() AssetsOption
- func EnableReloading(location string, after time.Time, loadNew bool) AssetsOption
- func OptionsFromFlags(rf *AssetsFlags) []AssetsOption
- func UseLogger(logger func(action reloadfs.Action, name, path string, err error)) AssetsOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAssets ¶
NewAssets returns an fs.FS that is configured to be optional reloaded from the local filesystem or to be served directly from the supplied fs.FS. The EnableReloading option is used to enable reloading. Prefix is prepended to all names passed to the supplied fs.FS, which is typically obtained via go:embed. See RelativeFS for more details.
func RelativeFS ¶
RelativeFS wraps the supplied FS so that prefix is prepended to all of the paths fetched from it. This is generally useful when working with webservers where the FS containing files is created from 'assets/...' but the URL path to access them is at the root. So /index.html can be mapped to assets/index.html.
Types ¶
type AssetsFlags ¶
type AssetsFlags struct { ReloadEnable bool `subcmd:"reload-enable,false,'if set, newer local filesystem versions of embedded asset files will be used'"` ReloadNew bool `subcmd:"reload-new-files,true,'if set, files that only exist on the local filesystem may be used'"` ReloadRoot string `` /* 380-byte string literal not displayed */ ReloadLogging bool `subcmd:"reload-logging,false,set to enable logging"` ReloadDebugging bool `subcmd:"reload-debugging,false,set to enable debug logging"` }
AssetsFlags represents the flags used to control loading of assets from the local filesystem to override those original embedded in the application binary.
type AssetsOption ¶
type AssetsOption func(a *assets)
AssetsOption represents an option to NewAssets.
func EnableLogging ¶
func EnableLogging() AssetsOption
EnableLogging enables logging using a built in logging function.
func EnableReloading ¶
func EnableReloading(location string, after time.Time, loadNew bool) AssetsOption
EnableReloading enables reloading of assets from the specified location if they have changed since 'after'; loadNew controls whether new files, ie. those that exist only in location, are loaded as opposed. See cloudeng.io/io/reloadfs.
func OptionsFromFlags ¶
func OptionsFromFlags(rf *AssetsFlags) []AssetsOption
OptionsFromFlags parses AssetsFlags to determine the options to be passed to NewAssets()