httpstandard

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 3 Imported by: 0

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

func BearerTokenExtractor(r *http.Request) string

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

type ActorExtractor func(*http.Request) string

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.

Jump to

Keyboard shortcuts

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