Documentation ¶
Index ¶
- type GinAssets
- func (a *GinAssets) HandlerFunc(paramName string) gin.HandlerFunc
- func (a GinAssets) StripOff(unwantedPrefixSegments int) *GinAssets
- func (a GinAssets) WithMaxAge(maxAge time.Duration) *GinAssets
- func (a GinAssets) WithNotFound(notFound http.Handler) *GinAssets
- func (a GinAssets) WithSPA() *GinAssets
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GinAssets ¶
type GinAssets servefiles.Assets
GinAssets is merely an adapter for servefiles.Assets with the same API and with an additional HandlerFunc method.
func NewAssetHandler ¶
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 ¶
NewAssetHandlerFS creates an Assets value for a given filesystem.
func NewAssetHandlerIoFS ¶
NewAssetHandlerIoFS creates an Assets value for a given filesystem.
func (*GinAssets) HandlerFunc ¶
func (a *GinAssets) HandlerFunc(paramName string) gin.HandlerFunc
HandlerFunc gets the asset handler as a Gin handler. The handler is registered using a catch-all path such as "/files/*filepath". The name of the catch-all parameter is passed in here (for example "filepath").
func (GinAssets) StripOff ¶
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 (GinAssets) WithMaxAge ¶
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 (GinAssets) WithNotFound ¶
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.