middlewares

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInStatusCode added in v0.5.8

func IsInStatusCode(code int, list []string) bool

Types

type AddPrefix

type AddPrefix struct {
	Prefix string `cfg:"prefix"`
}

func (*AddPrefix) Middleware

func (a *AddPrefix) Middleware() echo.MiddlewareFunc

type Auth

type Auth struct {
	Provider           auth.Provider     `cfg:"provider"`
	SkipSuffixes       []string          `cfg:"skip_suffixes"`
	Redirect           *redirect.Setting `cfg:"redirect"`
	InsecureSkipVerify bool              `cfg:"insecure_skip_verify"`
}

func (*Auth) Middleware

func (a *Auth) Middleware(ctx context.Context, name string) ([]echo.MiddlewareFunc, error)

type BasicAuth

type BasicAuth struct {
	Users []string `cfg:"users"`
	Realm string   `cfg:"realm"`
	// HeaderField is the name of the header field to set with the username
	HeaderField string `cfg:"header_field"`
	// RemoveHeader removes the Authorization header from the request
	RemoveHeader bool `cfg:"remove_header"`
}

func (*BasicAuth) Middleware

func (b *BasicAuth) Middleware(name string) ([]echo.MiddlewareFunc, error)

type Block

type Block struct {
	Methods   []string `cfg:"methods"`
	RegexPath string   `cfg:"regex_path"`
}

func (*Block) Middleware

func (m *Block) Middleware() (echo.MiddlewareFunc, error)

type Cors

type Cors struct {
	AllowOrigins                             []string `cfg:"allow_origins"`
	AllowMethods                             []string `cfg:"allow_methods"`
	AllowHeaders                             []string `cfg:"allow_headers"`
	AllowCredentials                         bool     `cfg:"allow_credentials"`
	UnsafeWildcardOriginWithAllowCredentials bool     `cfg:"unsafe_wildcard_origin_with_allow_credentials"`
	ExposeHeaders                            []string `cfg:"expose_headers"`
	MaxAge                                   int      `cfg:"max_age"`
}

func (*Cors) Middleware

func (c *Cors) Middleware() echo.MiddlewareFunc

type Decompress added in v0.3.6

type Decompress struct{}

func (*Decompress) Middleware added in v0.3.6

func (m *Decompress) Middleware() echo.MiddlewareFunc

type Folder

type Folder struct {
	// Path is the path to the folder
	Path string `cfg:"path"`
	// Index is automatically redirect to index.html
	Index bool `cfg:"index"`
	// StripIndexName is strip index name from url
	StripIndexName bool `cfg:"strip_index_name"`
	// IndexName is the name of the index file, default is index.html
	IndexName string `cfg:"index_name"`
	// SPA is automatically redirect to index.html
	SPA bool `cfg:"spa"`
	// SPAEnableFile is enable .* file to be served to index.html if not found, default is false
	SPAEnableFile bool `cfg:"spa_enable_file"`
	// SPAIndex is set the index.html location, default is IndexName
	SPAIndex string `cfg:"spa_index"`
	// SPAIndexRegex set spa_index from URL path regex
	SPAIndexRegex []*RegexPathStore `cfg:"spa_index_regex"`
	// Browse is enable directory browsing
	Browse bool `cfg:"browse"`
	// UTC browse time format
	UTC bool `cfg:"utc"`
	// PrefixPath for strip prefix path for real file path
	PrefixPath string `cfg:"prefix_path"`
	// FilePathRegex is regex replacement for real file path, comes after PrefixPath apply
	// File path doesn't include / suffix
	FilePathRegex []*RegexPathStore `cfg:"file_path_regex"`

	CacheRegex []*RegexCacheStore `cfg:"cache_regex"`
	// BrowseCache is cache control for browse page, default is no-cache
	BrowseCache string `cfg:"browse_cache"`

	DisableFolderSlashRedirect bool `cfg:"disable_folder_slash_redirect"`
	// contains filtered or unexported fields
}

func (*Folder) Cache added in v0.4.1

func (f *Folder) Cache(w http.ResponseWriter, fileName string)

func (*Folder) Middleware

func (f *Folder) Middleware() (echo.MiddlewareFunc, error)

func (*Folder) ServeContent added in v0.4.1

func (f *Folder) ServeContent(w http.ResponseWriter, req *http.Request, name string, modtime time.Time, content io.ReadSeeker)

func (*Folder) SetFs added in v0.5.5

func (f *Folder) SetFs(fs http.FileSystem)

type Gzip added in v0.3.6

type Gzip struct{}

func (*Gzip) Middleware added in v0.3.6

func (m *Gzip) Middleware() echo.MiddlewareFunc

type Headers

type Headers struct {
	CustomRequestHeaders  map[string]string `cfg:"custom_request_headers"`
	CustomResponseHeaders map[string]string `cfg:"custom_response_headers"`
}

Headers is a middleware that allows to add custom headers to the request and response.

Delete the header, set empty values.

func (*Headers) Middleware

func (h *Headers) Middleware() echo.MiddlewareFunc

type Hello

type Hello struct {
	// Message to return, default is "OK"
	Message string `cfg:"message"`
	// Status code to return, default is 200
	StatusCode int               `cfg:"status_code"`
	Headers    map[string]string `cfg:"headers"`

	// Type of return (json, json-pretty, html, string), default is string
	Type string `cfg:"type"`

	// Template to render go template
	Template bool `cfg:"template"`
	// Trust is allow to use powerful functions
	Trust bool `cfg:"trust"`
	// WorkDir is the directory for some functions
	WorkDir string `cfg:"work_dir"`
	// Delims is the delimiters for the template
	Delims []string `cfg:"delims"`
}

func (*Hello) Middleware

func (h *Hello) Middleware() ([]echo.MiddlewareFunc, error)

type Info

type Info struct {
	// Cookie to show.
	Cookie string `cfg:"cookie"`
	// Session cookie.
	Session bool `cfg:"session"`
	// SessionStoreName to get from auth_echo.
	SessionStoreName string `cfg:"session_store_name"`
	// SessionValueName to get from session, default is "cookie".
	SessionValueName string `cfg:"session_value_name"`
	// Base64 decode when reading cookie.
	Base64 bool `cfg:"base64"`
	// Raw cookie to show
	Raw bool `cfg:"raw"`
}

func (*Info) Middleware

func (s *Info) Middleware() echo.MiddlewareFunc

type Inject added in v0.4.4

type Inject struct {
	PathMap map[string][]InjectContent `cfg:"path_map"`
	// ContentMap is the mime type to inject like "text/html"
	ContentMap map[string][]InjectContent `cfg:"content_map"`
}

func (*Inject) Middleware added in v0.4.4

func (s *Inject) Middleware() ([]echo.MiddlewareFunc, error)

type InjectContent added in v0.4.4

type InjectContent struct {

	// Regex is the regex to match the content.
	//  - If regex is not empty, Old will be ignored.
	Regex string `cfg:"regex"`
	// Old is the old content to replace.
	Old string `cfg:"old"`

	New string `cfg:"new"`

	AddPrefix  string `cfg:"add_prefix"`
	AddPostfix string `cfg:"add_postfix"`

	// Value from load name, key value and type is map[string]interface{}
	Value string `cfg:"value"`
	// contains filtered or unexported fields
}

type LoadBalancer

type LoadBalancer struct {
	Servers []Server `cfg:"servers"`
}

type Log added in v0.3.6

type Log struct {
	Level   string `cfg:"level"`
	Message string `cfg:"message"`
	Headers bool   `cfg:"headers"`
}

func (*Log) LevelCheck added in v0.3.6

func (m *Log) LevelCheck() error

func (*Log) Middleware added in v0.3.6

func (m *Log) Middleware() ([]echo.MiddlewareFunc, error)

type Print added in v0.5.3

type Print struct {
	// Text after to print
	Text string `cfg:"text"`
}

func (*Print) Middleware added in v0.5.3

func (m *Print) Middleware() (echo.MiddlewareFunc, error)

type Redirect added in v0.6.4

type Redirect struct {
	Regex       string `cfg:"regex"`
	Replacement string `cfg:"replacement"`
	// contains filtered or unexported fields
}

type Redirection added in v0.5.8

type Redirection struct {
	URL       string `cfg:"url"`
	Permanent bool   `cfg:"permanent"`
}

func (*Redirection) Middleware added in v0.5.8

func (m *Redirection) Middleware() (echo.MiddlewareFunc, error)

type RedirectionContinue added in v0.6.4

type RedirectionContinue struct {
	Redirects []Redirect `cfg:"redirects"`

	Permanent bool `cfg:"permanent"`
}

func (*RedirectionContinue) Middleware added in v0.6.4

func (m *RedirectionContinue) Middleware() (echo.MiddlewareFunc, error)

type RegexCacheStore added in v0.4.1

type RegexCacheStore struct {
	Regex        string `cfg:"regex"`
	CacheControl string `cfg:"cache_control"`
	// contains filtered or unexported fields
}

type RegexPath added in v0.3.6

type RegexPath struct {
	Regex       string `cfg:"regex"`
	Replacement string `cfg:"replacement"`
}

func (*RegexPath) Middleware added in v0.3.6

func (m *RegexPath) Middleware() ([]echo.MiddlewareFunc, error)

type RegexPathStore added in v0.4.0

type RegexPathStore struct {
	Regex       string `cfg:"regex"`
	Replacement string `cfg:"replacement"`
	// contains filtered or unexported fields
}

type Request added in v0.5.8

type Request struct {
	URLRgx  string            `cfg:"url_rgx"`
	URL     string            `cfg:"url"`
	Method  string            `cfg:"method"`
	Body    string            `cfg:"body"`
	Headers map[string]string `cfg:"headers"`

	InsecureSkipVerify bool `cfg:"insecure_skip_verify"`
	EnableRetry        bool `cfg:"enable_retry"`
	// contains filtered or unexported fields
}

func (*Request) Middleware added in v0.5.8

func (m *Request) Middleware() (echo.MiddlewareFunc, error)

type Role

type Role struct {
	Roles   []string `cfg:"roles"`
	Methods []string `cfg:"methods"`
}

func (*Role) Middleware

func (m *Role) Middleware() echo.MiddlewareFunc

type Scope

type Scope struct {
	Scopes  []string `cfg:"scopes"`
	Methods []string `cfg:"methods"`
}

func (*Scope) Middleware

func (m *Scope) Middleware() echo.MiddlewareFunc

type Server

type Server struct {
	URL string `cfg:"url"`
}

type Service

type Service struct {
	InsecureSkipVerify bool         `cfg:"insecure_skip_verify"`
	PassHostHeader     bool         `cfg:"pass_host_header"`
	LoadBalancer       LoadBalancer `cfg:"loadbalancer"`
}

func (*Service) Middleware

func (m *Service) Middleware() ([]echo.MiddlewareFunc, error)

type Set

type Set struct {
	Values []string               `cfg:"values"`
	Map    map[string]interface{} `cfg:"map"`
}

Set to set flag.

Usable for other middlewares.

func (*Set) Middleware

func (s *Set) Middleware() echo.MiddlewareFunc

type StripPrefix

type StripPrefix struct {
	// ForceSlash default is true
	ForceSlash *bool    `cfg:"force_slash"`
	Prefixes   []string `cfg:"prefixes"`
	Prefix     string   `cfg:"prefix"`
}

func (*StripPrefix) Middleware

func (a *StripPrefix) Middleware() echo.MiddlewareFunc

type Template added in v0.5.1

type Template struct {
	Template string `cfg:"template"`
	// RawBody is the value of the body is raw or is an interface{}
	RawBody bool `cfg:"raw_body"`
	// Status code to return, default is from response
	StatusCode int `cfg:"status_code"`
	// Value from load name, key value and type is map[string]interface{}
	Value string `cfg:"value"`
	// Additional is additional values for the template
	Additional map[string]interface{} `cfg:"additional"`
	// Headers are additional to return
	Headers map[string]string `cfg:"headers"`
	// ApplyStatusCodes on specific status codes
	ApplyStatusCodes []int `cfg:"apply_status_codes"`

	// Trust is allow to use powerful functions
	Trust bool `cfg:"trust"`
	// WorkDir is the directory for some functions
	WorkDir string `cfg:"work_dir"`
	// Delims is the delimiters for the template
	Delims []string `cfg:"delims"`
	// contains filtered or unexported fields
}

func (*Template) Middleware added in v0.5.1

func (s *Template) Middleware() (echo.MiddlewareFunc, error)

type TokenPass added in v0.6.3

type TokenPass struct {
	SecretKey     string `cfg:"secret_key"`
	SigningMethod string `cfg:"signing_method"`
	// Payload with go template as claims
	Payload string `cfg:"payload"`

	// Redirect URL with go template
	RedirectURL      string `cfg:"redirect_url"`
	RedirectWithCode bool   `cfg:"redirect_with_code"`
	Method           string `cfg:"method"`
	EnableBody       bool   `cfg:"enable_body"`
	BodyRaw          bool   `cfg:"body_raw"`
	BodyTemplate     string `cfg:"body"`

	AdditionalValues   interface{} `cfg:"additional_values"`
	DefaultExpDuration string      `cfg:"default_exp_duration"`

	InsecureSkipVerify bool              `cfg:"insecure_skip_verify"`
	EnableRetry        bool              `cfg:"enable_retry"`
	Headers            map[string]string `cfg:"headers"`

	DebugToken   bool `cfg:"debug_token"`
	DebugPayload bool `cfg:"debug_payload"`
	// contains filtered or unexported fields
}

func (*TokenPass) Middleware added in v0.6.3

func (m *TokenPass) Middleware() (echo.MiddlewareFunc, error)

type Try added in v0.5.8

type Try struct {
	Regex       string `cfg:"regex"`
	Replacement string `cfg:"replacement"`

	// StatusCodes is a comma separated list of status codes to redirect
	//   300-399, 401, 403, 404, 405, 408, 410, 500-505
	StatusCodes string `cfg:"status_codes"`
}

func (*Try) Middleware added in v0.5.8

func (m *Try) Middleware() (echo.MiddlewareFunc, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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