static

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: MIT Imports: 7 Imported by: 0

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 {
	// Enables StaticFile service.
	Enable bool

	// 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
}

Config describes file location and controls access to them.

func (*Config) Forbids

func (cfg *Config) Forbids(filename string) bool

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

func (*Config) Valid

func (cfg *Config) Valid() error

Valid validates existence of directory.

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 service.Config, c service.Container) (enabled bool, err 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 (*Service) Serve

func (s *Service) Serve() error

Serve serves the service.

func (*Service) Stop

func (s *Service) Stop()

Stop stops the service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳