plugin

package
v0.4.14 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: MIT Imports: 14 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// Plugin types
	PluginBodyLimit           = "body-limit"
	PluginLogger              = "logger"
	PluginRedirect            = "redirect"
	PluginHTTPSRedirect       = "https-redirect"
	PluginHTTPSWWWRedirect    = "https-www-redirect"
	PluginHTTPSNonWWWRedirect = "https-non-www-redirect"
	PluginWWWRedirect         = "www-redirect"
	PluginNonWWWRedirect      = "non-www-redirect"
	PluginAddTrailingSlash    = "add-trailing-slash"
	PluginRemoveTrailingSlash = "remove-trailing-slash"
	PluginRewrite             = "rewrite"
	PluginSecure              = "secure"
	PluginCORS                = "cors"
	PluginGzip                = "gzip"
	PluginHeader              = "header"
	PluginProxy               = "proxy"
	PluginStatic              = "static"
	PluginFile                = "file"
)

Variables

View Source
var (

	// DefaultLookup function
	DefaultLookup = func(base Base) (p Plugin) {
		switch base.Name() {
		case PluginBodyLimit:
			p = &BodyLimit{Base: base}
		case PluginLogger:
			p = &Logger{Base: base}
		case PluginRedirect:
			p = &Redirect{Base: base}
		case PluginHTTPSRedirect:
			p = &HTTPSRedirect{Base: base}
		case PluginHTTPSWWWRedirect:
			p = &HTTPSWWWRedirect{Base: base}
		case PluginHTTPSNonWWWRedirect:
			p = &HTTPSNonWWWRedirect{Base: base}
		case PluginWWWRedirect:
			p = &WWWRedirect{Base: base}
		case PluginNonWWWRedirect:
			p = &NonWWWRedirect{Base: base}
		case PluginAddTrailingSlash:
			p = &AddTrailingSlash{Base: base}
		case PluginRemoveTrailingSlash:
			p = &RemoveTrailingSlash{Base: base}
		case PluginRewrite:
			p = &Rewrite{Base: base}
		case PluginSecure:
			p = &Secure{Base: base}
		case PluginCORS:
			p = &CORS{Base: base}
		case PluginGzip:
			p = &Gzip{Base: base}
		case PluginHeader:
			p = &Header{Base: base}
		case PluginProxy:
			p = &Proxy{Base: base}
		case PluginStatic:
			p = &Static{Base: base}
		case PluginFile:
			p = &File{Base: base}
		}
		return
	}

	// Lookup function
	Lookup = DefaultLookup
)

Functions

This section is empty.

Types

type AddTrailingSlash

type AddTrailingSlash struct {
	Base                           `yaml:",squash"`
	middleware.TrailingSlashConfig `yaml:",squash"`
}

func (*AddTrailingSlash) Initialize

func (s *AddTrailingSlash) Initialize()

func (*AddTrailingSlash) Process

func (s *AddTrailingSlash) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*AddTrailingSlash) Update added in v0.4.12

func (s *AddTrailingSlash) Update(p Plugin)

type Base

type Base struct {

	// TODO: to disable
	Skip       string              `yaml:"skip"`
	Middleware echo.MiddlewareFunc `yaml:"-"`
	Echo       *echo.Echo          `yaml:"-"`
	Logger     *log.Logger         `yaml:"-"`
	// contains filtered or unexported fields
}

Base defines the base struct for plugins.

func (*Base) Name

func (b *Base) Name() string

func (*Base) Order added in v0.4.14

func (b *Base) Order() int

type BodyLimit

type BodyLimit struct {
	Base                       `yaml:",squash"`
	middleware.BodyLimitConfig `yaml:",squash"`
}

func (*BodyLimit) Initialize

func (b *BodyLimit) Initialize()

func (*BodyLimit) Process

func (b *BodyLimit) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*BodyLimit) Update added in v0.4.12

func (b *BodyLimit) Update(p Plugin)

type CORS

type CORS struct {
	Base                  `yaml:",squash"`
	middleware.CORSConfig `yaml:",squash"`
}

func (*CORS) Initialize

func (c *CORS) Initialize()

func (*CORS) Process

func (c *CORS) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*CORS) Update added in v0.4.12

func (c *CORS) Update(p Plugin)

type Expression added in v0.2.7

type Expression struct {
	*fasttemplate.Template
}

func NewExpression added in v0.2.7

func NewExpression(t string) *Expression

func (*Expression) Evaluate added in v0.2.7

func (e *Expression) Evaluate(c echo.Context) (interface{}, error)

type File added in v0.2.1

type File struct {
	Base       `yaml:",squash"`
	FileConfig `yaml:",squash"`
}

func (*File) Initialize added in v0.4.12

func (f *File) Initialize()

func (*File) Process added in v0.2.1

func (f *File) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*File) Update added in v0.4.12

func (f *File) Update(p Plugin)

type FileConfig added in v0.4.12

type FileConfig struct {
	Path string `yaml:"path"`
}

type Gzip

type Gzip struct {
	Base                  `yaml:",squash"`
	middleware.GzipConfig `yaml:",squash"`
}

func (*Gzip) Initialize

func (g *Gzip) Initialize()

func (*Gzip) Process

func (g *Gzip) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*Gzip) Update added in v0.4.12

func (g *Gzip) Update(p Plugin)

type HTTPSNonWWWRedirect

type HTTPSNonWWWRedirect struct {
	Base                      `yaml:",squash"`
	middleware.RedirectConfig `yaml:",squash"`
}

func (*HTTPSNonWWWRedirect) Initialize

func (r *HTTPSNonWWWRedirect) Initialize()

func (*HTTPSNonWWWRedirect) Process

func (r *HTTPSNonWWWRedirect) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*HTTPSNonWWWRedirect) Update added in v0.4.12

func (r *HTTPSNonWWWRedirect) Update(p Plugin)

type HTTPSRedirect

type HTTPSRedirect struct {
	Base                      `yaml:",squash"`
	middleware.RedirectConfig `yaml:",squash"`
}

func (*HTTPSRedirect) Initialize

func (r *HTTPSRedirect) Initialize()

func (*HTTPSRedirect) Process

func (r *HTTPSRedirect) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*HTTPSRedirect) Update added in v0.4.12

func (r *HTTPSRedirect) Update(p Plugin)

type HTTPSWWWRedirect

type HTTPSWWWRedirect struct {
	Base                      `yaml:",squash"`
	middleware.RedirectConfig `yaml:",squash"`
}

func (*HTTPSWWWRedirect) Initialize

func (r *HTTPSWWWRedirect) Initialize()

func (*HTTPSWWWRedirect) Process

func (r *HTTPSWWWRedirect) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*HTTPSWWWRedirect) Update added in v0.4.12

func (r *HTTPSWWWRedirect) Update(p Plugin)
type Header struct {
	Base         `yaml:",squash"`
	HeaderConfig `yaml:",squash"`
}

func (*Header) Initialize

func (*Header) Initialize()

func (*Header) Process

func (h *Header) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*Header) Update added in v0.4.12

func (h *Header) Update(p Plugin)

type HeaderConfig added in v0.4.12

type HeaderConfig struct {
	Set map[string]string `yaml:"set"`
	Add map[string]string `yaml:"add"`
	Del []string          `yaml:"del"`
}

type Logger

type Logger struct {
	Base                    `yaml:",squash"`
	middleware.LoggerConfig `yaml:",squash"`
}

func (*Logger) Initialize

func (l *Logger) Initialize()

func (*Logger) Process

func (l *Logger) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*Logger) Update added in v0.4.12

func (l *Logger) Update(p Plugin)

type NonWWWRedirect

type NonWWWRedirect struct {
	Base                      `yaml:",squash"`
	middleware.RedirectConfig `yaml:",squash"`
}

func (*NonWWWRedirect) Initialize

func (r *NonWWWRedirect) Initialize()

func (*NonWWWRedirect) Process

func (r *NonWWWRedirect) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*NonWWWRedirect) Update added in v0.4.12

func (r *NonWWWRedirect) Update(p Plugin)

type Plugin

type Plugin interface {
	Name() string
	Initialize()
	Update(Plugin)
	Process(echo.HandlerFunc) echo.HandlerFunc
	Order() int
}

func Decode

func Decode(r RawPlugin, e *echo.Echo, l *log.Logger) (p Plugin)

Decode searches the plugin by name, decodes the provided map into plugin.

type Proxy

type Proxy struct {
	Base                   `yaml:",squash"`
	middleware.ProxyConfig `yaml:",squash"`
	Balance                string    `yaml:"balance"`
	Targets                []*Target `yaml:"targets"`
}

func (*Proxy) AddTarget added in v0.4.12

func (p *Proxy) AddTarget(c echo.Context) (err error)

func (*Proxy) Initialize

func (p *Proxy) Initialize()

func (*Proxy) Process

func (p *Proxy) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*Proxy) RemoveTarget added in v0.4.12

func (p *Proxy) RemoveTarget(c echo.Context) error

func (*Proxy) Update added in v0.4.12

func (p *Proxy) Update(plugin Plugin)

type RawPlugin added in v0.4.12

type RawPlugin map[string]interface{}

func (RawPlugin) JSON added in v0.4.12

func (rp RawPlugin) JSON() []byte

func (RawPlugin) Name added in v0.4.12

func (rp RawPlugin) Name() string

func (RawPlugin) Order added in v0.4.14

func (rp RawPlugin) Order() int

type Redirect

type Redirect struct {
	Base           `yaml:",squash"`
	RedirectConfig `yaml:",squash"`
}

func (*Redirect) Initialize

func (r *Redirect) Initialize()

func (*Redirect) Process

func (r *Redirect) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*Redirect) Update added in v0.4.12

func (r *Redirect) Update(p Plugin)

type RedirectConfig added in v0.4.12

type RedirectConfig struct {
	From string `yaml:"from"`
	To   string `yaml:"to"`
	Code int    `yaml:"code"`
	// contains filtered or unexported fields
}

type RemoveTrailingSlash

type RemoveTrailingSlash struct {
	Base                           `yaml:",squash"`
	middleware.TrailingSlashConfig `yaml:",squash"`
}

func (*RemoveTrailingSlash) Initialize

func (s *RemoveTrailingSlash) Initialize()

func (*RemoveTrailingSlash) Process

func (s *RemoveTrailingSlash) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*RemoveTrailingSlash) Update added in v0.4.12

func (s *RemoveTrailingSlash) Update(p Plugin)

type Rewrite

type Rewrite struct {
	Base                     `json:",squash"`
	middleware.RewriteConfig `json:",squash"`
}

func (*Rewrite) Initialize added in v0.4.12

func (r *Rewrite) Initialize()

func (*Rewrite) Process added in v0.4.12

func (r *Rewrite) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*Rewrite) Update added in v0.4.12

func (r *Rewrite) Update(p Plugin)

type Secure

type Secure struct {
	Base                    `yaml:",squash"`
	middleware.SecureConfig `yaml:",squash"`
}

func (*Secure) Initialize

func (s *Secure) Initialize()

func (*Secure) Process

func (s *Secure) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*Secure) Update added in v0.4.12

func (s *Secure) Update(p Plugin)

type Static

type Static struct {
	Base                    `yaml:",squash"`
	middleware.StaticConfig `yaml:",squash"`
}

func (*Static) Initialize

func (s *Static) Initialize()

func (*Static) Process

func (s *Static) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*Static) Update added in v0.4.12

func (s *Static) Update(p Plugin)

type Target

type Target struct {
	Name string `yaml:"name"`
	URL  string `yaml:"url"`
}

func (Target) ProxyTarget added in v0.4.12

func (t Target) ProxyTarget() (target *middleware.ProxyTarget, err error)

type Template added in v0.2.1

type Template struct {
	*fasttemplate.Template
}

func NewTemplate added in v0.2.1

func NewTemplate(t string) *Template

func (*Template) Execute added in v0.2.1

func (t *Template) Execute(c echo.Context) (string, error)

type WWWRedirect

type WWWRedirect struct {
	Base                      `yaml:",squash"`
	middleware.RedirectConfig `yaml:",squash"`
}

func (*WWWRedirect) Initialize

func (r *WWWRedirect) Initialize()

func (*WWWRedirect) Process

func (r *WWWRedirect) Process(next echo.HandlerFunc) echo.HandlerFunc

func (*WWWRedirect) Update added in v0.4.12

func (r *WWWRedirect) Update(p Plugin)

Jump to

Keyboard shortcuts

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