Documentation ¶
Index ¶
- func AuthMw(next http.Handler, m Matcher) http.HandlerFunc
- func Compress(next http.Handler) http.HandlerFunc
- func DefAuthMw(next http.Handler) http.HandlerFunc
- func DefLogsMw(next http.Handler) http.HandlerFunc
- func LoggerFromCtx(ctx context.Context) *log.Logger
- func LoggerFromRequest(r *http.Request) *log.Logger
- func LogsMw(requestIDKey string, next http.Handler) http.HandlerFunc
- func MetricsMw(dur prometheus.ObserverVec, bp prometheus.Observer, next http.Handler) http.HandlerFunc
- func RoleAuthMw(next http.Handler, allowedRole string) http.HandlerFunc
- func SetAllowedRole(role string)
- func SetClientID(id string)
- type KeyFunc
- type Matcher
- type MatcherFunc
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 ¶
LoggerFromCtx - logger getter from context
func LoggerFromRequest ¶
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 ¶
func MetricsMw(dur prometheus.ObserverVec, bp prometheus.Observer, next http.Handler) http.HandlerFunc
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
Types ¶
type KeyFunc ¶
type KeyFunc func() string
KeyFunc returns header keys for match
func RoleKeyFunc ¶
RoleKeyFunc returns the func, which returns the X-Auth-Access-Roles header key with service ID
type MatcherFunc ¶
MatcherFunc is func implementation of Matcher
func HeaderMatcher ¶
func HeaderMatcher(kf KeyFunc, input string) MatcherFunc
HeaderMatcher matches existence of the given header value