Documentation ¶
Index ¶
- func AcceptsEncoding(accepts, encoding string) bool
- func RegisterAssets(stats *AssetStats, assets map[string][]byte, base string, mapper AssetMapper)
- type AssetMapper
- type AssetResource
- type AssetStats
- func (as *AssetStats) AddCompressed(size int)
- func (as *AssetStats) AddJsCompressed(size int)
- func (as *AssetStats) AddJsTotal(size int)
- func (as *AssetStats) AddMapped(res AssetResource)
- func (as *AssetStats) AddSkipped(res AssetResource)
- func (as *AssetStats) AddTotal(size int)
- func (as AssetStats) Log(p logger.Printer)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcceptsEncoding ¶
func RegisterAssets ¶
func RegisterAssets(stats *AssetStats, assets map[string][]byte, base string, mapper AssetMapper)
RegisterAssets goes oever each asset supplied, creates an http handler, and registers it with AssetMapper.
assets is a dict generated via a go_embed_data target, basically a map between a path and byte array with the content of the file. base is a string determining the top level directory containing the assets, can be empty. mapper is a function in charge of mapping the asset and detected handler with the mux.
Example: if you set base to be "/data/", assets like "foo/bar/baz/data/test.html" will be mapped as "test.html", all that's after "/data/". Files not containing "/data/" will be skipped.
Types ¶
type AssetMapper ¶
type AssetMapper func(original, name string, handler khttp.FuncHandler) []string
func BasicMapper ¶
func BasicMapper(mapper AssetMapper) AssetMapper
BasicMapper registers the supplied files/assets with a normalized name.
Specifically: - leaves favicon.ico alone. - removes the .html extension. - maps index.html files to /.
func DefaultMapper ¶
func DefaultMapper(mux *http.ServeMux) AssetMapper
func MuxMapper ¶
func MuxMapper(mux *http.ServeMux) AssetMapper
MuxMapper simply registers a path as is with the mux.
func PrefixMapper ¶
func PrefixMapper(prefix string, mapper AssetMapper) AssetMapper
func StripExtensionMapper ¶
func StripExtensionMapper(mapper AssetMapper) AssetMapper
type AssetResource ¶
type AssetStats ¶
type AssetStats struct { Skipped []AssetResource Mapped []AssetResource Total, Compressed uint64 JsTotal, JsCompressed uint64 }
func (*AssetStats) AddCompressed ¶
func (as *AssetStats) AddCompressed(size int)
func (*AssetStats) AddJsCompressed ¶
func (as *AssetStats) AddJsCompressed(size int)
func (*AssetStats) AddJsTotal ¶
func (as *AssetStats) AddJsTotal(size int)
func (*AssetStats) AddMapped ¶
func (as *AssetStats) AddMapped(res AssetResource)
func (*AssetStats) AddSkipped ¶
func (as *AssetStats) AddSkipped(res AssetResource)
func (*AssetStats) AddTotal ¶
func (as *AssetStats) AddTotal(size int)
func (AssetStats) Log ¶
func (as AssetStats) Log(p logger.Printer)