middleware

package
v4.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package middleware provide router middleware

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection added in v4.4.0

type Collection []Middleware

Collection is a slice of handler wrappers functions

func NewCollection added in v4.4.0

func NewCollection(ms ...Middleware) Collection

NewCollection provides new middleware

func (Collection) Compose added in v4.4.0

func (c Collection) Compose(h Handler) Handler

Compose returns middleware composed to single WrapperFunc

func (Collection) Merge added in v4.4.0

func (c Collection) Merge(m Collection) Collection

Merge merges another middleware

func (Collection) Sort added in v4.4.0

func (c Collection) Sort() Collection

Sort sorts collection by priority

type Handler added in v4.4.0

type Handler interface{}

Handler represents wrapped function

type Middleware

type Middleware interface {
	// Wrap Handler with middleware
	Wrap(Handler) Handler
	// Priority provides a value for sorting Collection, lower values come first
	Priority() uint
}

Middleware wraps Handler

func WithPriority added in v4.4.0

func WithPriority(middleware Middleware, priority uint) Middleware

WithPriority provides new Middleware with priority

type WrapperFunc added in v4.4.0

type WrapperFunc func(Handler) Handler

WrapperFunc is an adapter to allow the use of handler wrapper functions as middleware functions.

func (WrapperFunc) Priority added in v4.4.0

func (f WrapperFunc) Priority() (priority uint)

Priority provides a value for sorting Collection, lower values come first

func (WrapperFunc) Wrap added in v4.4.0

func (f WrapperFunc) Wrap(h Handler) Handler

Wrap implements Wrapper interface

Jump to

Keyboard shortcuts

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