Files

12 lines
496 B
Go
Raw Permalink Normal View History

// Package httputil provides typed HTTP handler adapters and response helpers.
//
// The centrepiece is [Handle], a generics-based adapter that wraps a pure Go
// function into an [net/http.HandlerFunc], handling JSON decode, validation,
// and error mapping automatically:
//
// r.Get("/orders/{id}", httputil.Handle(validator, svc.GetOrder))
//
// Error responses are mapped from [xerrors.Code] to HTTP status codes.
// All response helpers set Content-Type: application/json.
package httputil