middleware

package
v0.56.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"vef:middleware",
	fx.Provide(
		fx.Annotate(
			NewRequestIDMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			NewLoggerMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			NewRecoveryMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			NewRequestRecordMiddleware,
			fx.ParamTags(`group:"vef:spa"`),
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			NewCORSMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			NewContentTypeMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			NewBodyEncodingMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			NewCompressionMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			NewHeadersMiddleware,
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
		fx.Annotate(
			NewSPAMiddleware,
			fx.ParamTags(`group:"vef:spa"`),
			fx.ResultTags(`group:"vef:app:middlewares"`),
		),
	),
)

Functions

func NewBodyEncodingMiddleware added in v0.41.0

func NewBodyEncodingMiddleware(appConfig *config.AppConfig, apiConfig *config.APIConfig) (app.Middleware, error)

NewBodyEncodingMiddleware manages X-Body-Encoding on the /api surface. With protected body transport disabled it preserves the opt-in request-only base64 and gzip+base64 behavior. With it enabled, JSON request bodies must use the configured authenticated encoding and every JSON response body is encoded with the same marker. Multipart and binary bodies remain untouched.

The native Content-Encoding path (gzip/br/deflate/zstd) is handled by Fiber itself with the same body-limit guard; this middleware covers the encodings Fiber does not know — base64 and gzip+base64.

func NewCORSMiddleware added in v0.32.0

func NewCORSMiddleware(config *config.CORSConfig) app.Middleware

func NewCompressionMiddleware

func NewCompressionMiddleware(config *config.APIConfig) app.Middleware

func NewContentTypeMiddleware

func NewContentTypeMiddleware() app.Middleware

NewContentTypeMiddleware enforces JSON/multipart for state-changing requests on the API surface, where the dispatcher parses JSON bodies. Other surfaces (MCP, the storage proxy, the integration inbound gateway) own their body formats — a vendor callback may legitimately POST XML.

func NewHeadersMiddleware

func NewHeadersMiddleware() app.Middleware

NewHeadersMiddleware sets headers after handler execution to avoid being overwritten by application code.

func NewLoggerMiddleware

func NewLoggerMiddleware() app.Middleware

NewLoggerMiddleware creates request-scoped loggers to correlate all log entries within a request.

func NewRecoveryMiddleware

func NewRecoveryMiddleware() app.Middleware

func NewRequestIDMiddleware

func NewRequestIDMiddleware() app.Middleware

func NewRequestRecordMiddleware

func NewRequestRecordMiddleware(spaConfigs []*middleware.SPAConfig) app.Middleware

NewRequestRecordMiddleware skips SPA static assets to reduce log noise while capturing API traffic.

func NewSPAMiddleware

func NewSPAMiddleware(configs []*middleware.SPAConfig) app.Middleware

Types

type SimpleMiddleware

type SimpleMiddleware struct {
	// contains filtered or unexported fields
}

func (*SimpleMiddleware) Apply

func (m *SimpleMiddleware) Apply(router fiber.Router)

func (*SimpleMiddleware) Name

func (m *SimpleMiddleware) Name() string

func (*SimpleMiddleware) Order

func (m *SimpleMiddleware) Order() int

Jump to

Keyboard shortcuts

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