Documentation ¶
Index ¶
- type EchoAssets
- func (a *EchoAssets) HandlerFunc(path string) echo.HandlerFunc
- func (a *EchoAssets) Register(e *echo.Echo, path string)
- func (a EchoAssets) StripOff(unwantedPrefixSegments int) *EchoAssets
- func (a EchoAssets) WithMaxAge(maxAge time.Duration) *EchoAssets
- func (a EchoAssets) WithNotFound(notFound http.Handler) *EchoAssets
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EchoAssets ¶
type EchoAssets servefiles.Assets
EchoAssets is merely an adapter for servefiles.Assets with the same API and with an additional HandlerFunc method.
func NewAssetHandler ¶
func NewAssetHandler(assetPath string) *EchoAssets
NewAssetHandler creates an Assets value. The parameter is the directory containing the asset files; this can be absolute or relative to the directory in which the server process is started.
This function cleans (i.e. normalises) the asset path.
func NewAssetHandlerFS ¶
func NewAssetHandlerFS(fs afero.Fs) *EchoAssets
NewAssetHandlerFS creates an Assets value for a given filesystem.
func (*EchoAssets) HandlerFunc ¶
func (a *EchoAssets) HandlerFunc(path string) echo.HandlerFunc
HandlerFunc gets the asset handler as an Echo handler. The handler is registered using a catch-all path such as "/files/*". The same match-any pattern can be passed in, in which case it is stripped off the leading part of the URL path seem by the asset handler.
func (*EchoAssets) Register ¶
func (a *EchoAssets) Register(e *echo.Echo, path string)
Register registers the asset handler with an Echo engine using the specified path to handle GET and HEAD requests.
The handler is registered using a catch-all path such as "/files/*". This pattern will be stripped off the leading part of the URL path seem by the asset handler when determining the file to be served.
func (EchoAssets) StripOff ¶
func (a EchoAssets) StripOff(unwantedPrefixSegments int) *EchoAssets
StripOff alters the handler to strip off a specified number of segments from the path before looking for the matching asset. For example, if StripOff(2) has been applied, the requested path "/a/b/c/d/doc.js" would be shortened to "c/d/doc.js".
The returned handler is a new copy of the original one.
func (EchoAssets) WithMaxAge ¶
func (a EchoAssets) WithMaxAge(maxAge time.Duration) *EchoAssets
WithMaxAge alters the handler to set the specified max age on the served assets.
The returned handler is a new copy of the original one.
func (EchoAssets) WithNotFound ¶
func (a EchoAssets) WithNotFound(notFound http.Handler) *EchoAssets
WithNotFound alters the handler so that 404-not found cases are passed to a specified handler. Without this, the default handler is the one provided in the net/http package.
The returned handler is a new copy of the original one.