fileserver

package module
v5.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 8 Imported by: 1

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cfg

type Cfg struct {
	// Prefix HTTP
	Prefix string `mapstructure:"prefix"`

	// Dir contains name of directory to control access to.
	// Default - "."
	Root string `mapstructure:"root"`

	BytesRange    bool `mapstructure:"bytes_range"`
	Compress      bool `mapstructure:"compress"`
	CacheDuration int  `mapstructure:"cache_duration"`
	MaxAge        int  `mapstructure:"max_age"`
}

type Config

type Config struct {
	// Address to serve
	Address string `mapstructure:"address"`
	// CalculateEtag can be true/false and used to calculate etag for the static
	CalculateEtag bool `mapstructure:"calculate_etag"`
	// Weak etag `W/`
	Weak bool `mapstructure:"weak"`
	// per-root configuration
	Configuration []*Cfg `mapstructure:"serve"`
	// StreamRequestBody ...
	StreamRequestBody bool `mapstructure:"stream_request_body"`
}

func (*Config) Valid

func (c *Config) Valid() error

type Configurer

type Configurer interface {
	// UnmarshalKey takes a single key and unmarshal it into a Struct.
	UnmarshalKey(name string, out any) error
	// Has checks if a config section exists.
	Has(name string) bool
}

type Logger

type Logger interface {
	NamedLogger(name string) *zap.Logger
}

type Plugin

type Plugin struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Plugin) Init

func (p *Plugin) Init(cfg Configurer, log Logger) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Serve

func (p *Plugin) Serve() chan error

func (*Plugin) Stop

func (p *Plugin) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

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