Documentation ¶
Index ¶
- Variables
- func DefaultSkipper(ctx echo.Context) bool
- func NoCache(h http.Handler) http.Handler
- func PageCache(e *echo.Echo, class string, ...) func(http.Handler) http.Handler
- func Recoverer(logger log.Logger) func(http.Handler) http.Handler
- func Static(root string) func(http.Handler) http.Handler
- func StaticWithConfig(config StaticConfig) func(http.Handler) http.Handler
- func WithDynamic(e *echo.Echo) func(http.Handler) http.Handler
- type BeforeFunc
- type Skipper
- type StaticConfig
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultStaticConfig is the default Static middleware config. DefaultStaticConfig = StaticConfig{ Skipper: DefaultSkipper, Index: "index.html", } )
Functions ¶
func DefaultSkipper ¶
DefaultSkipper returns false which processes the middleware.
func NoCache ¶
NoCache is a simple piece of middleware that sets a number of HTTP headers to prevent a router (or subrouter) from being cached by an upstream proxy and/or client.
As per http://wiki.nginx.org/HttpProxyModule - NoCache sets:
Expires: Thu, 01 Jan 1970 00:00:00 UTC Cache-Control: no-cache, private, max-age=0 X-Accel-Expires: 0 Pragma: no-cache (for HTTP/1.0 proxies/clients)
func PageCache ¶
func PageCache( e *echo.Echo, class string, dependencies func(c echo.Context) (map[string]string, error), duration time.Duration, ) func(http.Handler) http.Handler
Cached is middleware for cache whole html page.
func Recoverer ¶
Recoverer is a middleware that recovers from panics, logs the panic (and a backtrace), and returns a HTTP 500 (Internal Server Error) status if possible. Recoverer prints a request ID if one is provided.
Alternatively, look at https://github.com/pressly/lg middleware pkgs.
func Static ¶
Static returns a Static middleware to serves static content from the provided root directory.
func StaticWithConfig ¶
func StaticWithConfig(config StaticConfig) func(http.Handler) http.Handler
StaticWithConfig returns a Static middleware with config. See `Static()`.
Types ¶
type BeforeFunc ¶
BeforeFunc defines a function which is executed just before the middleware.
type Skipper ¶
Skipper defines a function to skip middleware. Returning true skips processing the middleware.
type StaticConfig ¶
type StaticConfig struct { // Skipper defines a function to skip middleware. Skipper Skipper // Root directory from where the static content is served. // Required. Root string `yaml:"root"` // Index file for serving a directory. // Optional. Default value "index.html". Index string `yaml:"index"` // Enable HTML5 mode by forwarding all not-found requests to root so that // SPA (single-page application) can handle the routing. // Optional. Default value false. HTML5 bool `yaml:"html5"` // Enable directory browsing. // Optional. Default value false. Browse bool `yaml:"browse"` }
StaticConfig defines the config for Static middleware.