mw

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2019 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthMw

func AuthMw(next http.Handler, m Matcher) http.HandlerFunc

AuthMw check the matcher value. If true - refers to next http.Handler, if false - returns 403 http status

func Compress added in v0.0.2

func Compress(next http.Handler) http.HandlerFunc

CompressHandler gzip compresses HTTP responses for clients that support it via the 'Accept-Encoding' header.

func DefAuthMw

func DefAuthMw(next http.Handler) http.HandlerFunc

DefAuthMw checks X-Auth-Access-Roles header with default role

func DefLogsMw

func DefLogsMw(next http.Handler) http.HandlerFunc

DefLogsMw - default LogsMw() middleware with requestID = 'X-Request-Id'

func LoggerFromCtx

func LoggerFromCtx(ctx context.Context) *log.Logger

LoggerFromCtx - logger getter from context

func LoggerFromRequest

func LoggerFromRequest(r *http.Request) *log.Logger

LoggerFromRequest - logger getter from request context

func LogsMw

func LogsMw(requestIDKey string, next http.Handler) http.HandlerFunc

LogsMw creates logger with specified prefix (requestID)

func MetricsMw

MetricsMw add http duration metric and BP metric

func RoleAuthMw

func RoleAuthMw(next http.Handler, allowedRole string) http.HandlerFunc

RoleAuthMw checks the X-Auth-Access-Roles header with given role

func SetAllowedRole

func SetAllowedRole(role string)

SetAllowedRole aloowed role setter

func SetClientID

func SetClientID(id string)

SetClientID client ID setter

Types

type KeyFunc

type KeyFunc func() string

KeyFunc returns header keys for match

func RoleKeyFunc

func RoleKeyFunc(cid string) KeyFunc

RoleKeyFunc returns the func, which returns the X-Auth-Access-Roles header key with service ID

type Matcher

type Matcher interface {
	Match(*http.Request) bool
}

Matcher checks access of request

type MatcherFunc

type MatcherFunc func(*http.Request) bool

MatcherFunc is func implementation of Matcher

func HeaderMatcher

func HeaderMatcher(kf KeyFunc, input string) MatcherFunc

HeaderMatcher matches existence of the given header value

func (MatcherFunc) Match

func (m MatcherFunc) Match(r *http.Request) bool

Match is MatcherFunc method

Jump to

Keyboard shortcuts

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