Documentation
¶
Index ¶
Constants ¶
View Source
const (
// ErrCategory static serve error category
ErrCategory = "elton-static-serve"
)
Variables ¶
View Source
var ( // ErrNotAllowQueryString not all query string ErrNotAllowQueryString = getStaticServeError("static serve not allow query string", http.StatusBadRequest) // ErrNotFound static file not found ErrNotFound = getStaticServeError("static file not found", http.StatusNotFound) // ErrOutOfPath file out of path ErrOutOfPath = getStaticServeError("out of path", http.StatusBadRequest) // ErrNotAllowAccessDot file include dot ErrNotAllowAccessDot = getStaticServeError("static server not allow with dot", http.StatusBadRequest) )
Functions ¶
func New ¶
func New(staticFile StaticFile, config Config) elton.Handler
New create a static serve middleware
func NewDefault ¶
NewDefault create a static server milldeware use FS
Types ¶
type Config ¶
type Config struct { // 静态文件目录 Path string // http cache control max age MaxAge int // http cache control s-maxage SMaxAge int // http response header Header map[string]string // 禁止query string(因为有时静态文件为CDN回源,避免生成各种重复的缓存) DenyQueryString bool // 是否禁止文件路径以.开头(因为这些文件有可能包括重要信息) DenyDot bool // 是否使用strong etag EnableStrongETag bool // 禁止生成ETag DisableETag bool // 禁止生成 last-modifed DisableLastModified bool // 如果404,是否调用next执行后续的中间件(默认为不执行,返回404错误) NotFoundNext bool Skipper elton.Skipper }
Config static serve config
Click to show internal directories.
Click to hide internal directories.