middleware

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 32 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(cfg *config.AppConfig) app.Middleware

NewBodyEncodingMiddleware decodes an opt-in X-Body-Encoding request body back to raw JSON before the dispatcher parses it, so a client can transport-encode code-shaped payloads (integration adapter scripts, envelope/auth scripts, dry-run bodies) past middleboxes that false-positive on them. The decode is transport-only: storage, content-hash caches and audit all see the raw body. A request without the header is untouched, and only the /api surface is eligible (other surfaces own their body formats).

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() 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