Documentation
¶
Index ¶
- Variables
- func DecodeJSON(r *http.Request, v any) error
- func FormField(r *http.Request, key string) (string, error)
- func NumberParam[T Number](r *http.Request, key string) (T, error)
- func Payload[T any](r *http.Request) (T, error)
- func PayloadMap(r *http.Request) (map[string]any, error)
- func PayloadWithValidate[T any](r *http.Request) (T, error)
- func QueryPayload[T any](r *http.Request) (T, error)
- func QueryPayloadWithValidate[T any](r *http.Request) (T, error)
- type Number
- type Pager
Constants ¶
This section is empty.
Variables ¶
var MaxPageSize = 1000
MaxPageSize is the maximum allowed page size to prevent resource exhaustion.
var MaxRequestBodySize int64 = 5 << 20 // 5MB
MaxRequestBodySize is the maximum allowed size for request bodies (5MB default). This prevents resource exhaustion attacks from large payloads. Override this value if you need to accept larger requests.
Functions ¶
func DecodeJSON ¶ added in v0.3.0
DecodeJSON decodes JSON from the request body into the provided pointer. The body size is limited by MaxRequestBodySize to prevent DoS attacks.
func NumberParam ¶
NumberParam from request query string
func QueryPayload ¶ added in v0.4.1
QueryPayload decodes URL query parameters into a value of type T. T must be a struct. Field names are taken from the `query` struct tag, falling back to the `json` tag, then the field name itself. Supported kinds are string, bool, signed and unsigned integers, floats, and slices of those types. Pointer fields are populated only when the corresponding key is present in the query string. Slice values may be supplied either by repeating the key (?id=1&id=2) or by a single comma-separated value (?id=1,2).