static

package
v2.0.0-beta.24 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName = "static"

ID contains default service name.

View Source
const RootPluginName = "http"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Static *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

		// Request headers to add to every static.
		Request map[string]string

		// Response headers to add to every static.
		Response map[string]string
	}
}

Config describes file location and controls access to them.

func (*Config) AlwaysForbid

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

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

func (*Config) AlwaysServe

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

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

func (*Config) Valid

func (c *Config) Valid() error

Valid returns nil if config is valid.

type Plugin

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

Plugin serves static files. Potentially convert into middleware?

func (*Plugin) Init

func (s *Plugin) Init(cfg config.Configurer, log logger.Logger) 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.

func (*Plugin) Middleware

func (s *Plugin) Middleware(next http.Handler) http.HandlerFunc

middleware must return true if request/response pair is handled within the middleware.

func (*Plugin) Name

func (s *Plugin) Name() string

Jump to

Keyboard shortcuts

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