httpx

package
v0.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package httpx holds the HTTP plumbing shared by notifycat's 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).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Signature

func Signature(maxBytes int64, authenticate Authenticate) func(http.Handler) http.Handler

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.

Types

type Authenticate

type Authenticate func(w http.ResponseWriter, r *http.Request, body []byte) bool

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").

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL