Documentation
¶
Index ¶
- Variables
- func BuildRoutes(config Config) (map[string]Route, error)
- func CompressAll(compression Compression, r io.Reader) ([]byte, error)
- func Execute() error
- func IsAtty(file *os.File) bool
- func Max[T constraints.Ordered](a, b T) T
- type ByteSize
- type Cache
- type Compression
- type Config
- type Creator
- type Handler
- type Nonce
- type NoncedRoute
- type Route
- type RouteFlag
- type StaticRoute
Constants ¶
This section is empty.
Variables ¶
View Source
var Brotli = compression{ // contains filtered or unexported fields }
View Source
var Deflate = compression{ // contains filtered or unexported fields }
View Source
var ErrNonNonceable = errors.New("route is not nonceable")
View Source
var GZIP = compression{ // contains filtered or unexported fields }
View Source
var Identity = identity{}
Functions ¶
func CompressAll ¶
func CompressAll(compression Compression, r io.Reader) ([]byte, error)
func Max ¶
func Max[T constraints.Ordered](a, b T) T
Types ¶
type Cache ¶
type Compression ¶
type Compression interface {
Wrap(io.Writer) io.WriteCloser
WriteEncodingHeader(http.ResponseWriter)
AddExtension(string) string
}
type Config ¶
type Config struct {
Address string `short:"a" long:"address" description:"address to listen to" default:"0.0.0.0"`
Port int `short:"p" long:"port" description:"port to listen on" default:"80"`
Compression struct {
NoGZIP bool `long:"no-gzip" description:"disable gzip compression"`
NoDeflate bool `long:"no-deflate" description:"disable deflate compression"`
NoBrotli bool `long:"no-brotli" description:"disable brotli compression"`
Threshold ByteSize `long:"threshold" description:"file size threshold to enable compression" default:"1k"`
} `group:"compression" namespace:"compression"`
Cache struct {
MaxAge time.Duration `long:"max-age" description:"cache max age on cacheable file, i.e. files with an hash" default:"168h" default-mask:"1 week"`
Ignore []string `short:"N" long:"no-store" description:"additional files to set Cache-Control: no-store"`
MaxSize ByteSize `short:"m" long:"max-size" description:"maximal size of the cache in bytes" default:"50M"`
NoInMemoryRoot bool `` /* 171-byte string literal not displayed */
} `group:"cache-control" namespace:"cache"`
CSP struct {
Disable bool `long:"nonce-disable" description:"Disable CSP Nonce generation"`
NoncedPath []string `short:"O" long:"nonced" description:"list of nonced file" default:"/index.html"`
Policy string `` /* 140-byte string literal not displayed */
} `group:"csp-nonce" namespace:"csp"`
Args struct {
Directory string `description:"directory to serve (default: '.')" positional-arg-name:"directory"`
} `positional-args:"yes"`
}
func (*Config) EnabledCompressions ¶
func (c *Config) EnabledCompressions() []Compression
type NoncedRoute ¶
type NoncedRoute struct {
// contains filtered or unexported fields
}
func (NoncedRoute) Flags ¶
func (r NoncedRoute) Flags() RouteFlag
func (NoncedRoute) PreCache ¶
func (r NoncedRoute) PreCache()
func (NoncedRoute) ServeHTTP ¶
func (r NoncedRoute) ServeHTTP(w http.ResponseWriter, req *http.Request)
type Route ¶
type Route interface {
ServeHTTP(http.ResponseWriter, *http.Request)
PreCache()
Flags() RouteFlag
}
type StaticRoute ¶
type StaticRoute struct {
// contains filtered or unexported fields
}
func (StaticRoute) Flags ¶
func (r StaticRoute) Flags() RouteFlag
func (StaticRoute) PreCache ¶
func (r StaticRoute) PreCache()
func (StaticRoute) ServeHTTP ¶
func (r StaticRoute) ServeHTTP(w http.ResponseWriter, req *http.Request)
Click to show internal directories.
Click to hide internal directories.