Documentation ¶
Index ¶
- Variables
- func RegisterConstraintType(factory func() Constraint)
- type AbortRequestError
- type Constraint
- type Constraints
- func (cs *Constraints) MarshalJSON() ([]byte, error)
- func (cs *Constraints) ProcessRequestForm(form *url.Values, onSecurityFail OnSecurityFail) error
- func (cs *Constraints) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (cs *Constraints) UnmarshalJSON(data []byte) error
- func (cs *Constraints) Validate() error
- type Middleware
- func (*Middleware) CaddyModule() caddy.ModuleInfo
- func (m *Middleware) Provision(ctx caddy.Context) error
- func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
- func (m *Middleware) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (m *Middleware) Validate() error
- type OnFail
- type OnSecurityFail
- type RangeConstraint
- type SecurityOptions
- type ValuesConstraint
Constants ¶
This section is empty.
Variables ¶
View Source
var BypassRequestError = errors.New("bypass request")
Functions ¶
func RegisterConstraintType ¶
func RegisterConstraintType(factory func() Constraint)
Types ¶
type AbortRequestError ¶
type AbortRequestError struct {
Msg string
}
func (*AbortRequestError) Error ¶
func (e *AbortRequestError) Error() string
type Constraint ¶
type Constraints ¶
type Constraints map[string][]Constraint
Constraints represent constraints as {params:[{type:..., customConfig..}]}
func (*Constraints) MarshalJSON ¶
func (cs *Constraints) MarshalJSON() ([]byte, error)
MarshalJSON serializes Constraints to JSON, adding a `type` field to each entry.
func (*Constraints) ProcessRequestForm ¶
func (cs *Constraints) ProcessRequestForm(form *url.Values, onSecurityFail OnSecurityFail) error
func (*Constraints) UnmarshalCaddyfile ¶
func (cs *Constraints) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
func (*Constraints) UnmarshalJSON ¶
func (cs *Constraints) UnmarshalJSON(data []byte) error
UnmarshalJSON deserializes JSON into Constraints, dynamically instantiating types using the registry.
func (*Constraints) Validate ¶
func (cs *Constraints) Validate() error
type Middleware ¶
type Middleware struct { OnFail OnFail `json:"on_fail,omitempty"` Security *SecurityOptions `json:"security,omitempty"` // contains filtered or unexported fields }
Middleware allow user to do image processing on the fly using libvips With simple queries parameters you can resize, convert, crop your served images
func (*Middleware) CaddyModule ¶
func (*Middleware) CaddyModule() caddy.ModuleInfo
func (*Middleware) Provision ¶
func (m *Middleware) Provision(ctx caddy.Context) error
func (*Middleware) ServeHTTP ¶
func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
func (*Middleware) UnmarshalCaddyfile ¶
func (m *Middleware) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
func (*Middleware) Validate ¶
func (m *Middleware) Validate() error
type OnSecurityFail ¶
type OnSecurityFail string
const ( // OnSecurityFailIgnore Deletes invalid parameters from the request but continues processing. OnSecurityFailIgnore OnSecurityFail = "ignore" // OnSecurityFailAbort Returns a 400 Bad Request error to the client. OnSecurityFailAbort OnSecurityFail = "abort" // OnSecurityFailBypass Forces the response to return the initial (unprocessed) image. OnSecurityFailBypass OnSecurityFail = "bypass" )
type RangeConstraint ¶
func (*RangeConstraint) ID ¶
func (r *RangeConstraint) ID() string
func (*RangeConstraint) UnmarshalCaddyfile ¶
func (r *RangeConstraint) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
func (*RangeConstraint) Validate ¶
func (r *RangeConstraint) Validate(param string) error
func (*RangeConstraint) ValidateParam ¶
func (r *RangeConstraint) ValidateParam(param string, value string) error
type SecurityOptions ¶
type SecurityOptions struct { OnSecurityFail OnSecurityFail `json:"on_security_fail,omitempty"` AllowedParams *[]string `json:"allowed_params,omitempty"` DisallowedParams *[]string `json:"disallowed_params,omitempty"` Constraints *Constraints `json:"constraints,omitempty"` }
func (*SecurityOptions) ProcessRequestForm ¶
func (s *SecurityOptions) ProcessRequestForm(form *url.Values) error
ProcessRequestForm Ensures that all security constraints are applied. May also remove specific parameters if they are not allowed.
func (*SecurityOptions) Provision ¶
func (s *SecurityOptions) Provision(ctx caddy.Context) error
Provision Set default values if not defined
func (*SecurityOptions) UnmarshalCaddyfile ¶
func (s *SecurityOptions) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
func (*SecurityOptions) Validate ¶
func (s *SecurityOptions) Validate() error
Validate ensure security parameters are correctly defined
type ValuesConstraint ¶
type ValuesConstraint struct {
Values []int `json:"values"`
}
func (*ValuesConstraint) ID ¶
func (r *ValuesConstraint) ID() string
func (*ValuesConstraint) UnmarshalCaddyfile ¶
func (r *ValuesConstraint) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
func (*ValuesConstraint) Validate ¶
func (r *ValuesConstraint) Validate(param string) error
func (*ValuesConstraint) ValidateParam ¶
func (r *ValuesConstraint) ValidateParam(param string, value string) error
Click to show internal directories.
Click to hide internal directories.