Documentation
¶
Overview ¶
Package req provides HTTP request parsing, validation, and input binding utilities.
It supports automatic parsing of request data from various sources (JSON, form data, query parameters, headers) into Go structs with validation support. The package integrates with httpin for flexible input binding and provides validation interfaces for request data validation.
Index ¶
- Constants
- func DecodeJSONBody(w http.ResponseWriter, r *http.Request, dst any) error
- func HasFormData(r *http.Request) bool
- func HasFormUrlEncoded(r *http.Request) bool
- func HasJSON(r *http.Request) bool
- func HasMultiPart(r *http.Request) bool
- func In(c Context, inputStruct any, opts ...core.Option) error
- func ParseInput(rr RequestResponder, inputStruct any, opts ...core.Option) error
- func WantsHTML(r *http.Request) bool
- func WantsJSON(r *http.Request) bool
- func WantsXML(r *http.Request) bool
- type Context
- type GetSetter
- type MalformedRequest
- type RequestResponder
- type Validator
Constants ¶
const InKey = "input"
Variables ¶
This section is empty.
Functions ¶
func DecodeJSONBody ¶
func HasFormData ¶
func HasFormUrlEncoded ¶ added in v0.1.5
func HasMultiPart ¶ added in v0.1.5
func ParseInput ¶
func ParseInput(rr RequestResponder, inputStruct any, opts ...core.Option) error
Types ¶
type Context ¶
type Context interface {
RequestResponder
GetSetter
}
Context combines request/response access with key-value storage. This interface is typically implemented by HTTP context types.
type GetSetter ¶
GetSetter provides key-value storage for request-scoped data. This allows storing and retrieving arbitrary values during request processing.
type MalformedRequest ¶
func (*MalformedRequest) Error ¶
func (mr *MalformedRequest) Error() string
type RequestResponder ¶
type RequestResponder interface {
Request() *http.Request
ResponseWriter() http.ResponseWriter
}
RequestResponder provides access to HTTP request and response writer. This interface is typically implemented by framework context types.