Documentation
¶
Overview ¶
Package httpstandard provides an adapter that bridges protosource's provider-agnostic handlers to standard net/http. Suitable for local development, container deployments, DigitalOcean App Platform, or any environment that speaks HTTP.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BearerTokenExtractor ¶
BearerTokenExtractor returns an ActorExtractor that reads the Authorization header and returns the bearer token value as the actor. This is a simple extractor for development/testing; in production, you'd typically validate the JWT and extract claims.
func Wrap ¶
func Wrap(handler protosource.HandlerFunc, extractor ActorExtractor) http.HandlerFunc
Wrap returns an http.HandlerFunc that converts between net/http and protosource's provider-agnostic types. The extractor populates the actor identity on each request.
func WrapRouter ¶
func WrapRouter(router *protosource.Router, extractor ActorExtractor) http.Handler
WrapRouter returns an http.Handler that dispatches to the router based on the request's HTTP method and URL path.
Types ¶
type ActorExtractor ¶
ActorExtractor extracts the actor identity from an HTTP request. Return an empty string if no identity can be determined.
func HeaderExtractor ¶
func HeaderExtractor(header string) ActorExtractor
HeaderExtractor returns an ActorExtractor that reads the actor identity from a specific HTTP header. Useful when a reverse proxy or API gateway sets a header like X-User-Id after authentication.