Documentation
¶
Overview ¶
Package httpx holds the HTTP plumbing shared by notifycat's handlers. For the signed-webhook receivers it owns only the parts that are identical across providers — capping and reading the body once, and replaying a fresh body reader downstream — and delegates authentication to a provider-supplied callback. The signing scheme itself (which headers, what HMAC, which error message) stays with each provider, because those genuinely differ (GitHub signs the raw body; Slack signs a timestamped base string).
It also holds the JSON writers, which send non-cacheable JSON responses, and Route, which pairs a ServeMux pattern with its handler so a domain can hand its routes to the composition root.
Index ¶
Constants ¶
const ( CacheControlHeader = "Cache-Control" NoStore = "no-store" )
Response caching headers set on every credential-bearing response.
const AllowHeader = "Allow"
AllowHeader lists the methods a 405 response accepts.
Variables ¶
This section is empty.
Functions ¶
func Signature ¶
Signature returns an HTTP middleware that rejects bodies larger than maxBytes (413), reads the body once, runs authenticate (which rejects unauthenticated requests itself), and otherwise replays a fresh body reader to next so downstream handlers read the verified bytes without touching the raw stream.
func WriteError ¶ added in v0.29.0
func WriteError(w http.ResponseWriter, status int, code string)
WriteError writes {"error": code} with the status.
func WriteJSON ¶ added in v0.29.0
func WriteJSON(w http.ResponseWriter, status int, body any)
WriteJSON writes body as a non-cacheable JSON response.
func WriteNoContent ¶ added in v0.29.0
func WriteNoContent(w http.ResponseWriter)
WriteNoContent writes a non-cacheable 204.
Types ¶
type Authenticate ¶
Authenticate verifies a request from its (already-read) raw body. On failure it writes the appropriate error response to w and returns false; on success it writes nothing and returns true. Keeping the failure response here — rather than returning an error the skeleton renders — lets each provider preserve its own status codes and messages (e.g. "missing signature" vs "invalid signature").