middleware

package
v0.0.0-...-4263410 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const InstanceTypeExpiration time.Duration = 4 * time.Hour

An InstanceTypeExpiration represents the default expiration time for instance types

View Source
const OpenAPIExpiration time.Duration = 30 * time.Minute

An OpenAPIExpiration represents the default expiration time for the OpenAPI JSON

Variables

View Source
var (
	ErrEnforceIdentityFirst = errors.New("missing identity in the context, use EnforceIdentity before EnforcePermissions")
	ErrMissingPermission    = errors.New("missing permission")
)
View Source
var InvalidETagErr = errors.New("empty etag provided")

An InvalidETagErr is returned to prevent empty tag generation

Functions

func AccountMiddleware

func AccountMiddleware(next http.Handler) http.Handler

func CorrelationID

func CorrelationID(next http.Handler) http.Handler

func ETagMiddleware

func ETagMiddleware(etagFunc ETagValueFunc) func(next http.Handler) http.Handler

func EnforcePermissions

func EnforcePermissions(resource, permission string) func(next http.Handler) http.Handler

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 LoggerMiddleware(rootLogger *zerolog.Logger) func(next http.Handler) http.Handler

func NewPatternMiddleware

func NewPatternMiddleware(name string) func(next http.Handler) http.Handler

NewPatternMiddleware returns a new prometheus Middleware handler that groups requests by the chi routing pattern. EX: /users/{firstName} instead of /users/bob

func Pagination

func Pagination(next http.Handler) http.Handler

Pagination middleware is used to extract the offset and the limit

func VersionMiddleware

func VersionMiddleware(next http.Handler) http.Handler

Types

type ETag

type ETag struct {
	Name       string
	Expiration time.Duration
	Value      string
	HashTime   time.Duration
}

An ETag represents W3C ETag caching header

func AllETags

func AllETags() []*ETag

AllETags returns all ETags for diagnostic purposes

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

func (etag *ETag) CacheControlHeader() string

func (*ETag) Header

func (etag *ETag) Header() string

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.

Jump to

Keyboard shortcuts

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