Documentation ¶
Index ¶
Constants ¶
View Source
const PkgName = "auxo.net.web.filter"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorizer ¶
type Authorizer struct { Checker func(user web.User, handler web.HandlerInfo) bool LoginURL string ForbiddenMsg string }
func NewAuthorizer ¶
func NewAuthorizer(checker func(user web.User, handler web.HandlerInfo) bool) *Authorizer
func (*Authorizer) Apply ¶
func (a *Authorizer) Apply(next web.HandlerFunc) web.HandlerFunc
Apply implements `web.Filter` interface.
type CORS ¶
type CORS struct { // AllowOrigin defines a list of origins that may access the resource. // Optional. Default value []string{"*"}. AllowOrigins []string // AllowMethods defines a list methods allowed when accessing the resource. // This is used in response to a preflight request. // Optional. Default value DefaultCORSConfig.AllowMethods. AllowMethods []string // AllowHeaders defines a list of request headers that can be used when // making the actual request. This in response to a preflight request. // Optional. Default value []string{}. AllowHeaders []string // AllowCredentials indicates whether or not the response to the request // can be exposed when the credentials flag is true. When used as part of // a response to a preflight request, this indicates whether or not the // actual request can be made using credentials. // Optional. Default value false. AllowCredentials bool // ExposeHeaders defines a whitelist headers that clients are allowed to // access. // Optional. Default value []string{}. ExposeHeaders []string // MaxAge indicates how long (in seconds) the results of a preflight request // can be cached. // Optional. Default value 0. MaxAge int }
CORS represents a Cross-Origin Resource Sharing (CORS) filter.
func (*CORS) Apply ¶
func (c *CORS) Apply(next web.HandlerFunc) web.HandlerFunc
Apply implements `web.Filter` interface.
type DynamicHeader ¶
DynamicHeader is a filter which can inject dynamic headers to response.
func NewCacheHeader ¶
func NewCacheHeader(expiry time.Duration) DynamicHeader
NewCacheHeader return a Header instance which adds `Expires` and `Cache-Control` headers.
func (DynamicHeader) Apply ¶
func (h DynamicHeader) Apply(next web.HandlerFunc) web.HandlerFunc
type Header ¶
Header is a filter which can inject headers to response.
func (Header) Apply ¶
func (h Header) Apply(next web.HandlerFunc) web.HandlerFunc
type Recover ¶
type Recover struct { // StackSize is max size of the stack to be logged. // Optional. Default value 4KB. StackSize int `json:"stack_size"` // StackEnabled enables logging stack trace. // Optional. Default value is true. StackEnabled bool `json:"stack_enabled"` }
func (*Recover) Apply ¶
func (r *Recover) Apply(next web.HandlerFunc) web.HandlerFunc
Apply implements `web.Filter` interface.
Click to show internal directories.
Click to hide internal directories.