static

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 7 Imported by: 9

Documentation

Index

Constants

View Source
const ID = "static"

ID contains default service name.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Dir contains name of directory to control access to.
	Dir string

	// Forbid specifies list of file extensions which are forbidden for access.
	// Example: .php, .exe, .bat, .htaccess and etc.
	Forbid []string

	// Always specifies list of extensions which must always be served by static
	// service, even if file not found.
	Always []string
}

Config describes file location and controls access to them.

func (*Config) AlwaysForbid added in v1.3.1

func (c *Config) AlwaysForbid(filename string) bool

AlwaysForbid must return true if file extension is not allowed for the upload.

func (*Config) AlwaysServe added in v1.3.1

func (c *Config) AlwaysServe(filename string) bool

AlwaysServe must indicate that file is expected to be served by static service.

func (*Config) Hydrate added in v1.1.0

func (c *Config) Hydrate(cfg service.Config) error

Hydrate must populate Config values using given Config source. Must return error if Config is not valid.

func (*Config) Valid

func (c *Config) Valid() error

Valid returns nil if config is valid.

type Service

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

Service serves static files. Potentially convert into middleware?

func (*Service) Init

func (s *Service) Init(cfg *Config, r *rrhttp.Service) (bool, error)

Init must return configure service and return true if service hasStatus enabled. Must return error in case of misconfiguration. Services must not be used without proper configuration pushed first.

Jump to

Keyboard shortcuts

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