Documentation
¶
Overview ¶
Package requestsource identifies which listener served a request. The public listener requires bootstrapping and authentication; the loopback-only admin listener answers without either. The edge middleware stores the source in the request context; business logic branches on it where behavior differs. A missing value reads as public, so unknown callers face authentication, never a bypass.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithSource ¶
func ContextWithSource(ctx context.Context, source RequestSource) context.Context
ContextWithSource returns ctx carrying source.
func Middleware ¶
func Middleware(source RequestSource) func(http.Handler) http.Handler
Middleware stores source in every request context reaching next.
Types ¶
type RequestSource ¶
type RequestSource int
RequestSource is the listener that served a request.
const ( // RequestSourcePublic requires bootstrapping and authentication. RequestSourcePublic RequestSource = iota // RequestSourcePrivate answers without authentication or // bootstrapping. It binds loopback only; the bind is the protection. RequestSourcePrivate )
func SourceFromContext ¶
func SourceFromContext(ctx context.Context) RequestSource
SourceFromContext returns the RequestSource in ctx, defaulting to RequestSourcePublic when absent so unknown callers face authentication.