static

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

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 WithPageContextFunc(fn func(req *http.Request) interface{}) option

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

func (m *Module) DefaultHandle500(rw http.ResponseWriter, req *http.Request, err error)

DefaultHandle500 default 500 handler

func (*Module) Init

func (m *Module) Init(c *service.Config)

Init this module

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.

func (*Module) ServeHTTP

func (m *Module) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL