Versions in this module Expand all Collapse all v0 v0.2.1 Mar 19, 2026 v0.2.0 Mar 19, 2026 Changes in this version + var ErrRequestBodyTooLarge = errors.New("request body too large") + type DecodeOption func(*decodeConfig) + func WithMaxBodySize(n int64) DecodeOption v0.1.5 Mar 16, 2026 v0.1.4 Mar 16, 2026 Changes in this version + var ErrInvalidContentType = errors.New("content-type contains invalid characters") + var ErrSSEPayloadTooLarge = errors.New("SSE event payload exceeds size limit") + var ErrStreamTruncated = errors.New("response stream truncated: source exceeded max bytes") + func GetClientIPE(r *http.Request, trustedProxyCIDRs []string) (string, error) + func GetClientIPWithNets(r *http.Request, trustedNets []*net.IPNet) string + func ParseTrustedProxyCIDRs(cidrs []string) ([]*net.IPNet, error) + func RenderStreamLimited(w http.ResponseWriter, contentType, filename string, rc io.Reader, ...) error + type HealthHandlerOption func(*healthOpts) + func HealthHideDetails() HealthHandlerOption + func HealthOnEncodeError(f func(error)) HealthHandlerOption + type Paginated struct + Data []T + Page int + PerPage int + Total int64 + TotalPages int + func FetchPage[T any](ctx context.Context, page, perPage int, ...) (*Paginated[T], error) + func NewPaginated[T any](data []T, total int64, page, perPage int) *Paginated[T] + type SSEOption func(*SSEWriter) + func MaxEventBytes(n int64) SSEOption type SSEWriter + func NewSSEWriterWithLimit(w http.ResponseWriter, opts ...SSEOption) (*SSEWriter, bool) + type ValidationHTTPError struct + Errors []ValidationErrorItem + func (e *ValidationHTTPError) Error() string + func (e *ValidationHTTPError) GetCode() string + func (e *ValidationHTTPError) HTTPStatus() int + func (e *ValidationHTTPError) Unwrap() error v0.1.3 Mar 15, 2026 Changes in this version + var ErrSSEClosed = errors.New("SSE writer closed") + func HealthHandler(checkers map[string]Checker) http.HandlerFunc + func ParseBoolQuery(r *http.Request, key string) (bool, bool) + func ParseEnumQuery[T ~string](r *http.Request, key string, allowed []T) (T, bool) + func ParseSortQuery(r *http.Request, allowedFields []string) (field, dir string, ok bool) + func ParseTimeQuery(r *http.Request, key, layout string) (time.Time, bool) + type Checker interface + Check func(ctx context.Context) error + type SSEWriter struct + func NewSSEWriter(w http.ResponseWriter) (*SSEWriter, bool) + func (s *SSEWriter) Close() + func (s *SSEWriter) Send(event, data string) error + func (s *SSEWriter) SendJSON(event string, v any) error v0.1.2 Mar 14, 2026 Changes in this version + func TotalPages(total int64, perPage int) int + type ErrorHandler struct + Logger ErrorLogger + func (h *ErrorHandler) Handle(w http.ResponseWriter, r *http.Request, err error, msg string) bool + type ErrorLogEvent interface + Error func(msg string) + Info func(msg string) + type ErrorLogger interface + WithError func(err error) ErrorLogEvent + func NewErrorLogger(l logger.Logger) ErrorLogger + type PaginationMeta struct + Page int + PerPage int + Total int + TotalPages int + func NewPaginationMeta(page, perPage int, total int64) PaginationMeta v0.1.1 Mar 13, 2026 Changes in this version + func ChiPathFromRequest(r *http.Request) string + func RenderAccepted[T any](w http.ResponseWriter, r *http.Request, data T) v0.1.0 Mar 13, 2026 Changes in this version + const DefaultSearchMaxLen + const MaxPage + const MaxRequestBodySize + const UserIDKey + func ClampLimit(p *int, defaultVal, maxVal int) int + func ClampPage(p *int) int + func ClampPerPage(p *int, defaultVal, maxVal int) int + func DecodeAndValidateE[T any](r *http.Request, v Validator) (T, error) + func DecodeAndValidate[T any](w http.ResponseWriter, r *http.Request, v Validator, log *slog.Logger, ...) (T, bool) + func DecodeJSON[T any](r *http.Request, v *T) error + func EscapeILIKE(s string, maxLen int) string + func GetClientIP(r *http.Request, trustedProxyCIDRs []string) string + func GetUserID(ctx context.Context) string + func HandleError(w http.ResponseWriter, r *http.Request, err error) + func ParseAuthUserID(w http.ResponseWriter, r *http.Request) (uuid.UUID, bool) + func ParseIntQuery(r *http.Request, key string) *int + func ParseMultipartFormLimit(w http.ResponseWriter, r *http.Request, maxMemory int64) bool + func ParseUUID(w http.ResponseWriter, r *http.Request, id string) (uuid.UUID, bool) + func ParseUUIDField(w http.ResponseWriter, r *http.Request, value, field string) (uuid.UUID, bool) + func Ptr[T any](v T) *T + func RenderBytes(w http.ResponseWriter, contentType, filename string, data []byte) error + func RenderCreated[T any](w http.ResponseWriter, r *http.Request, data T) + func RenderError(w http.ResponseWriter, r *http.Request, status int, message string) + func RenderErrorWithCode(w http.ResponseWriter, r *http.Request, status int, message, code string) + func RenderInvalidID(w http.ResponseWriter, r *http.Request) + func RenderJSONAttachment[T any](w http.ResponseWriter, data T, filename string) error + func RenderJSON[T any](w http.ResponseWriter, r *http.Request, status int, data T) + func RenderNoContent(w http.ResponseWriter, _ *http.Request) + func RenderOK[T any](w http.ResponseWriter, r *http.Request, data T) + func RenderStream(w http.ResponseWriter, contentType, filename string, rc io.Reader) error + func RenderText(w http.ResponseWriter, _ *http.Request, status int, contentType, body string) + func SanitizeSearchQ(q string, maxLen int) string + func ValidateSearchQ(q string) bool + type ErrorResponse struct + Code string + Message string + type ValidationErrorItem struct + Field string + Message string + type ValidationErrorResponse struct + Code string + Errors []ValidationErrorItem + Message string + type Validator interface + Validate func(any) error