Documentation
¶
Overview ¶
Package binding decodes HTTP request body, query, and path values into typed structs and returns api-toolkit field errors.
Use this package at transport boundaries when a handler needs a small, dependency-neutral decoder that produces the same validation Problem Details shape as the rest of the toolkit. Business validation and persistence rules should still live outside handlers.
Index ¶
- func DecodeJSON[T any](r *http.Request, cfg JSONConfig) (T, error)
- func DecodePath[T any](r *http.Request, cfg PathConfig) (T, error)
- func DecodeQuery[T any](r *http.Request, cfg QueryConfig) (T, error)
- func ValidationProblem(err error) httpx.Problem
- func WriteValidationProblem(w http.ResponseWriter, err error)
- type JSONConfig
- type PathConfig
- type QueryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeJSON ¶
func DecodeJSON[T any](r *http.Request, cfg JSONConfig) (T, error)
DecodeJSON decodes a JSON body into T.
func DecodePath ¶
func DecodePath[T any](r *http.Request, cfg PathConfig) (T, error)
DecodePath decodes route path parameters into T.
func DecodeQuery ¶
func DecodeQuery[T any](r *http.Request, cfg QueryConfig) (T, error)
DecodeQuery decodes query parameters into T.
func ValidationProblem ¶
ValidationProblem maps validation errors to a Problem Details payload.
func WriteValidationProblem ¶
func WriteValidationProblem(w http.ResponseWriter, err error)
WriteValidationProblem writes validation errors as RFC 9457 Problem Details.
Types ¶
type JSONConfig ¶
JSONConfig configures JSON request body decoding.
type PathConfig ¶
PathConfig configures path decoding.