Documentation ¶
Index ¶
- Constants
- Variables
- func AccountMiddleware(next http.Handler) http.Handler
- func CorrelationID(next http.Handler) http.Handler
- func ETagMiddleware(etagFunc ETagValueFunc) func(next http.Handler) http.Handler
- func EnforcePermissions(resource, permission string) func(next http.Handler) http.Handler
- func LoggerMiddleware(rootLogger *zerolog.Logger) func(next http.Handler) http.Handler
- func NewPatternMiddleware(name string) func(next http.Handler) http.Handler
- func Pagination(next http.Handler) http.Handler
- func VersionMiddleware(next http.Handler) http.Handler
- type ETag
- type ETagValueFunc
- type Middleware
Constants ¶
const InstanceTypeExpiration time.Duration = 4 * time.Hour
An InstanceTypeExpiration represents the default expiration time for instance types
const OpenAPIExpiration time.Duration = 30 * time.Minute
An OpenAPIExpiration represents the default expiration time for the OpenAPI JSON
Variables ¶
var ( ErrEnforceIdentityFirst = errors.New("missing identity in the context, use EnforceIdentity before EnforcePermissions") ErrMissingPermission = errors.New("missing permission") )
var InvalidETagErr = errors.New("empty etag provided")
An InvalidETagErr is returned to prevent empty tag generation
Functions ¶
func ETagMiddleware ¶
func ETagMiddleware(etagFunc ETagValueFunc) func(next http.Handler) http.Handler
func EnforcePermissions ¶
EnforcePermissions enforces permissions via RBAC service. It requires that identity is present in the context, make sure to chain EnforceIdentity middleware before this one.
func LoggerMiddleware ¶
func NewPatternMiddleware ¶
NewPatternMiddleware returns a new prometheus Middleware handler that groups requests by the chi routing pattern. EX: /users/{firstName} instead of /users/bob
func Pagination ¶
Pagination middleware is used to extract the offset and the limit
Types ¶
type ETag ¶
An ETag represents W3C ETag caching header
func GenerateETagFromBuffer ¶
func GenerateETagFromBuffer(name string, expiration time.Duration, buffers ...[]byte) (*ETag, error)
GenerateETagFromBuffer calculates etag value from one or more buffers (e.g. embedded files)
func (*ETag) CacheControlHeader ¶
type ETagValueFunc ¶
type ETagValueFunc func() *ETag
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware is a handler that exposes prometheus metrics for the number of requests, the latency and the response size, partitioned by status code, method and HTTP path.