ath

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 40 Imported by: 0

Documentation

Index

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 BuildRoutes

func BuildRoutes(config Config) (map[string]Route, error)

func CompressAll

func CompressAll(compression Compression, r io.Reader) ([]byte, error)

func Execute

func Execute() error

func IsAtty

func IsAtty(file *os.File) bool

func Max

func Max[T constraints.Ordered](a, b T) T

Types

type ByteSize

type ByteSize int64

func (ByteSize) MarshalFlag

func (s ByteSize) MarshalFlag() (string, error)

func (ByteSize) String

func (s ByteSize) String() string

func (*ByteSize) UnmarshalFlag

func (s *ByteSize) UnmarshalFlag(value string) error

type Cache

type Cache interface {
	Store(string, []byte)
	Get(string, Creator) ([]byte, error)
	Load(string) ([]byte, bool)
	Size() int64
}

func NewCache

func NewCache(maxSize int64) 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"`
	Verbose []bool `short:"v" long:"verbose" description:"Enable verbose logging for each request"`

	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"`
		Eligible  []string `` /* 230-byte string literal not displayed */
		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-Control max-age on unversionned files" default:"0s"`
	} `group:"cache-control" namespace:"cache"`

	ServerCache struct {
		RootFileInLRU bool     `` /* 189-byte string literal not displayed */
		MaxMemorySize ByteSize `short:"m" long:"max-size" description:"maximal size of the cache in bytes" default:"50M"`
	} `group:"server-cache" namespace:"server-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"`

	Otel struct {
		Endpoint          string `long:"endpoint" description:"Open Telemetry Collectore Endpoint"`
		ServiceName       string `long:"name" description:"Service name to report" default:"angular-to-http"`
		ServiceInstanceID string `long:"instance" description:"Service Instance ID, if empty hostname will be used"`
	} `group:"otel" namespace:"otel"`

	Args struct {
		Directory string `description:"directory to serve (default: '.')" positional-arg-name:"directory"`
	} `positional-args:"yes"`
}

func (*Config) AllowedCompressions

func (c *Config) AllowedCompressions() map[string]bool

func (*Config) EnabledCompressions

func (c *Config) EnabledCompressions() []Compression

type Creator

type Creator func() ([]byte, error)

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(routes map[string]Route) *Handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w_ http.ResponseWriter, req *http.Request)

type Nonce

type Nonce struct {
	Nonce string
}

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() int64

func (NoncedRoute) ServeHTTP

func (r NoncedRoute) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Route

type Route interface {
	ServeHTTP(http.ResponseWriter, *http.Request)
	PreCache() int64
	Flags() RouteFlag
}

type RouteFlag

type RouteFlag int
const (
	NONCED RouteFlag = 1 << iota
	IMMUTABLE
	COMPRESSIBLE
)

func (RouteFlag) String

func (f RouteFlag) String() string

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() int64

func (StaticRoute) ServeHTTP

func (r StaticRoute) ServeHTTP(w http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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