static

package
v2.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName = "static"

PluginName contains default service name.

View Source
const RootPluginName = "http"

Variables

This section is empty.

Functions

func SetEtag

func SetEtag(weak bool, f http.File, name string, w http.ResponseWriter)

SetEtag sets etag for the file

Types

type Config

type Config struct {
	// Dir contains name of directory to control access to.
	// Default - "."
	Dir string `mapstructure:"dir"`

	// 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"`

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

	// Allow specifies list of file extensions which are allowed for access.
	// example: .php, .exe, .bat, .htaccess and etc.
	Allow []string `mapstructure:"allow"`

	// Request headers to add to every static.
	Request map[string]string `mapstructure:"request"`

	// Response headers to add to every static.
	Response map[string]string `mapstructure:"response"`
}

Config describes file location and controls access to them.

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 *zap.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.Handler

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