gentleman.v2: gopkg.in/h2non/gentleman.v2/middleware Index | Files

package middleware

import "gopkg.in/h2non/gentleman.v2/middleware"

Package middleware implements an HTTP client domain-specific phase-oriented middleware layer used internally by gentleman packages.

Index

Package Files

middleware.go

type Layer Uses

type Layer struct {
    // contains filtered or unexported fields
}

Layer type represent an HTTP domain specific middleware layer with inheritance support.

func New Uses

func New() *Layer

New creates a new middleware layer.

func (*Layer) Clone Uses

func (s *Layer) Clone() Middleware

Clone creates a new Middleware instance based on the current one.

func (*Layer) Flush Uses

func (s *Layer) Flush()

Flush flushes the plugins stack.

func (*Layer) GetStack Uses

func (s *Layer) GetStack() []plugin.Plugin

GetStack gets the current middleware plugins stack.

func (*Layer) Run Uses

func (s *Layer) Run(phase string, ctx *c.Context) *c.Context

Run triggers the middleware call chain for the given phase.

func (*Layer) SetStack Uses

func (s *Layer) SetStack(stack []plugin.Plugin)

SetStack sets the middleware plugin stack overriding the existent one.

func (*Layer) Use Uses

func (s *Layer) Use(plugin plugin.Plugin) Middleware

Use registers a new plugin to the middleware stack.

func (*Layer) UseError Uses

func (s *Layer) UseError(fn c.HandlerFunc) Middleware

UseError registers a new error phase middleware handler.

func (*Layer) UseHandler Uses

func (s *Layer) UseHandler(phase string, fn c.HandlerFunc) Middleware

UseHandler registers a phase specific plugin handler in the middleware stack.

func (*Layer) UseParent Uses

func (s *Layer) UseParent(parent Middleware) Middleware

UseParent attachs a parent middleware.

func (*Layer) UseRequest Uses

func (s *Layer) UseRequest(fn c.HandlerFunc) Middleware

UseRequest registers a new request phase middleware handler.

func (*Layer) UseResponse Uses

func (s *Layer) UseResponse(fn c.HandlerFunc) Middleware

UseResponse registers a new response phase middleware handler.

type Middleware Uses

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.

Package middleware imports 3 packages (graph) and is imported by 6 packages. Updated 2020-02-18. Refresh now. Tools for package owners.