Documentation ¶
Overview ¶
Package middleware implements an HTTP client domain-specific phase-oriented middleware layer used internally by gentleman packages.
Index ¶
- type Layer
- func (s *Layer) Clone() Middleware
- func (s *Layer) Flush()
- func (s *Layer) GetStack() []plugin.Plugin
- func (s *Layer) Run(phase string, ctx *c.Context) *c.Context
- func (s *Layer) SetStack(stack []plugin.Plugin)
- func (s *Layer) Use(plugin plugin.Plugin) Middleware
- func (s *Layer) UseError(fn c.HandlerFunc) Middleware
- func (s *Layer) UseHandler(phase string, fn c.HandlerFunc) Middleware
- func (s *Layer) UseParent(parent Middleware) Middleware
- func (s *Layer) UseRequest(fn c.HandlerFunc) Middleware
- func (s *Layer) UseResponse(fn c.HandlerFunc) Middleware
- type Middleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Layer ¶
type Layer struct {
// contains filtered or unexported fields
}
Layer type represent an HTTP domain specific middleware layer with inheritance support.
func (*Layer) Clone ¶
func (s *Layer) Clone() Middleware
Clone creates a new Middleware instance based on the current one.
func (*Layer) Use ¶
func (s *Layer) Use(plugin plugin.Plugin) Middleware
Use registers a new plugin to the middleware stack.
func (*Layer) UseError ¶
func (s *Layer) UseError(fn c.HandlerFunc) Middleware
UseError registers a new error phase middleware handler.
func (*Layer) UseHandler ¶
func (s *Layer) UseHandler(phase string, fn c.HandlerFunc) Middleware
UseHandler registers a phase specific plugin handler in the middleware stack.
func (*Layer) UseParent ¶
func (s *Layer) UseParent(parent Middleware) Middleware
UseParent attachs a parent middleware.
func (*Layer) UseRequest ¶
func (s *Layer) UseRequest(fn c.HandlerFunc) Middleware
UseRequest registers a new request phase middleware handler.
func (*Layer) UseResponse ¶
func (s *Layer) UseResponse(fn c.HandlerFunc) Middleware
UseResponse registers a new response phase middleware handler.
type Middleware ¶
type Middleware interface { // Use method is used to register a new plugin in the middleware stack. Use(plugin.Plugin) Middleware // UseError is used to register a new error phase middleware function handler. UseError(c.HandlerFunc) Middleware // UseRequest is used to register a new request phase middleware function handler. UseRequest(c.HandlerFunc) Middleware // UseResposne is used to register a new resposne phase middleware function handler. UseResponse(c.HandlerFunc) Middleware // UseHandler is used to register a new phase specific middleware function handler. UseHandler(string, c.HandlerFunc) Middleware // Run is used to dispatch the middleware call chain for a specific phase. Run(string, *c.Context) *c.Context // UseParent defines a parent middleware for easy inheritance. UseParent(Middleware) Middleware // Clone is used to created a new clone of the existent middleware. Clone() Middleware // Flush is used to flush the middleware stack. Flush() // GetStack is used to retrieve an array of registered plugins. GetStack() []plugin.Plugin // SetStack is used to override the stack of registered plugins. SetStack([]plugin.Plugin) }
Middleware especifies the required interface that must be implemented by middleware capable interfaces.