querylimits

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package querylimits provides stable core query-parameter guardrail middleware.

Use New with Options when handlers need bounded query parameter counts, key lengths, value lengths, and pagination limit values before application parsing. Middleware and Handler expose the same guardrail for ports.Middleware wiring or direct net/http usage.

Invalid query shapes fail with Problem Details 400 responses and do not reach the wrapped handler. The package does not parse business filters or database queries; use queryparams for typed collection-query parsing after these size and limit checks pass.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorWriter

type ErrorWriter func(http.ResponseWriter, int, httpx.Problem)

ErrorWriter allows overriding how validation errors are written.

type Middleware

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

Middleware enforces query parameter limits.

func New

func New(opts Options) (*Middleware, error)

New constructs a query limits middleware with safe defaults.

func (*Middleware) Handler

func (m *Middleware) Handler(next http.Handler) http.Handler

Handler wraps the next handler with query guardrails.

func (*Middleware) Middleware

func (m *Middleware) Middleware() func(http.Handler) http.Handler

Middleware implements ports.Middleware via Handler adapter.

type Options

type Options struct {
	MaxParams      int
	MaxKeyLength   int
	MaxValueLength int
	LimitParam     string
	MaxLimit       int
	ErrorWriter    ErrorWriter
}

Options configures query parameter limits.

Jump to

Keyboard shortcuts

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