Documentation ¶
Index ¶
- func WithBox(box fileSource) option
- func WithExcludedPrefixes(prefixes ...string) option
- func WithHandle404(fn http.HandlerFunc) option
- func WithHandle500(fn func(rw http.ResponseWriter, req *http.Request, err error)) option
- func WithPageContextFunc(fn func(req *http.Request) interface{}) option
- func WithStaticBase(dir string) option
- func WithStaticDirs(dirs ...string) option
- type Module
- func (m *Module) Configure(opts ...option)
- func (m *Module) DefaultHandle404(rw http.ResponseWriter, req *http.Request)
- func (m *Module) DefaultHandle500(rw http.ResponseWriter, req *http.Request, err error)
- func (m *Module) Init(c *service.Config)
- func (m *Module) ServeAsset(rw http.ResponseWriter, req *http.Request, filepath string, ...)
- func (m *Module) ServeAssetWithContext(rw http.ResponseWriter, req *http.Request, filepath string, ...)
- func (m *Module) ServeHTTP(rw http.ResponseWriter, req *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBox ¶
func WithBox(box fileSource) option
WithBox configures the static module with a source
func WithExcludedPrefixes ¶
func WithExcludedPrefixes(prefixes ...string) option
WithExcludedPrefixes allows certain paths to be excluded from serving static assets.
func WithHandle404 ¶
func WithHandle404(fn http.HandlerFunc) option
WithHandle404 configures static module with a base URL path for serving static assets
func WithHandle500 ¶
func WithHandle500(fn func(rw http.ResponseWriter, req *http.Request, err error)) option
WithHandle500 configures static module with a base URL path for serving static assets
func WithPageContextFunc ¶
func WithStaticBase ¶
func WithStaticBase(dir string) option
WithStaticBase configures static module with a base URL path for serving static assets
func WithStaticDirs ¶
func WithStaticDirs(dirs ...string) option
WithStaticDirs configures static modules with valid paths to respond to (must begin with the staticBasePath)
Types ¶
type Module ¶
type Module struct { Router *router.Module Logger *logger.Module // contains filtered or unexported fields }
Module static serves static files
func (*Module) Configure ¶
func (m *Module) Configure(opts ...option)
Configure this module with given options
func (*Module) DefaultHandle404 ¶
func (m *Module) DefaultHandle404(rw http.ResponseWriter, req *http.Request)
DefaultHandle404 default 404 handler
func (*Module) DefaultHandle500 ¶
DefaultHandle500 default 500 handler
func (*Module) ServeAsset ¶
func (m *Module) ServeAsset(rw http.ResponseWriter, req *http.Request, filepath string, customErrHandler bool)
ServeAsset serves a filepath from the packr box. handle404 and handle500 should not recurse.
func (*Module) ServeAssetWithContext ¶
func (m *Module) ServeAssetWithContext(rw http.ResponseWriter, req *http.Request, filepath string, customErrHandler bool)
ServeAssetWithContext serves a file like ServeAsset, except is process it as a template file and injects the page context. todo: cache templates.