Documentation
¶
Overview ¶
Package http provides transport-independent HTTP responses, JSON decoding and application error mapping. Import it as pfwhttp alongside net/http.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeJSON ¶
func DecodeJSON[T any](r *stdhttp.Request, options DecodeOptions) (T, error)
DecodeJSON reads one JSON value, enforcing content type and body size. Request errors are *Error values with a safe public message and internal cause.
Types ¶
type DecodeOptions ¶
type Error ¶
type Error struct {
Status int `json:"-"`
Code string `json:"code"`
Message string `json:"message"`
Fields map[string]string `json:"fields,omitempty"`
// contains filtered or unexported fields
}
Error describes a public HTTP error. Its status and internal cause are not serialized, and domain errors need not import this package.
type ErrorMapper ¶
ErrorMapper is the contract used by HTTP consumers. Implementations map application errors and write their public response without exposing causes.
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.