middleware

package
v0.0.0-...-6d1cdc8 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClientPrincipalNameHeader = "X-Ms-Client-Principal-Name"
	ClientAADTypeHeader       = "X-Ms-Client-Principal-Type"
)

Variables

This section is empty.

Functions

func ContextWithClientPrincipal

func ContextWithClientPrincipal(ctx context.Context, clientPrincipalReference ClientPrincipalReference) context.Context

func ContextWithOriginalUrlPathValue

func ContextWithOriginalUrlPathValue(ctx context.Context, originalUrlPathValue string) context.Context

func ContextWithPattern

func ContextWithPattern(ctx context.Context, pattern *string) context.Context

func ContextWithUrlPathValue

func ContextWithUrlPathValue(ctx context.Context, urlPathValue string) context.Context

func MiddlewareClientPrincipal

func MiddlewareClientPrincipal(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

MiddlewareClientPrincipal validates and extracts client principal information from request headers.

func MiddlewareHCPResourceID

func MiddlewareHCPResourceID(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

MiddlewareHCPResourceID extracts and validates the HCP resource ID from the request path and stores it in the request context.

func MiddlewareLogger

func MiddlewareLogger(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

MiddlewareLogger attaches a request-specific logger to the request context.

func MiddlewareLowercase

func MiddlewareLowercase(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

MiddlewareLowercase lowercases the URL path and adds the original and lowercase URL path values to the context.

func NewMiddlewareAudit

func NewMiddlewareAudit(auditClient audit.Client) *middlewareAudit

func OriginalUrlPathValueFromContext

func OriginalUrlPathValueFromContext(ctx context.Context) (string, error)

func PatternFromContext

func PatternFromContext(ctx context.Context) *string

func UrlPathValueFromContext

func UrlPathValueFromContext(ctx context.Context) (string, error)

func V1HCPResourcePattern

func V1HCPResourcePattern(method string, pattern string) string

HCPResourcePattern returns a mux pattern for an HCP resource endpoint. It combines the method, the /admin/v1/hcp prefix, the standard Azure resource path segments, and the given suffix pattern.

Types

type ClientPrincipalReference

type ClientPrincipalReference struct {
	Name string
	Type PrincipalType
}

func ClientPrincipalFromContext

func ClientPrincipalFromContext(ctx context.Context) (ClientPrincipalReference, error)

type ContextError

type ContextError struct {
	// contains filtered or unexported fields
}

func (*ContextError) Error

func (c *ContextError) Error() string

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

Middleware is a list of middleware functions to execute before invoking an http.Handler.

func NewMiddleware

func NewMiddleware(functions ...MiddlewareFunc) *Middleware

NewMiddleware allocates and returns a new Middleware.

func (*Middleware) Handler

func (m *Middleware) Handler(handler http.Handler) http.Handler

Handler returns an http.Handler that invokes the list of middleware functions before invoking the given HTTP handler. Pass the returned http.Handler to http.ServeMux.Handle to add middleware functions that execute after pattern-based multiplexing occurs and values for path wildcards are available via http.Request.PathValue.

func (*Middleware) HandlerFunc

func (m *Middleware) HandlerFunc(handler func(http.ResponseWriter, *http.Request)) http.Handler

HandlerFunc returns an http.Handler that invokes the list of middleware functions before invoking the given HTTP handler function. Pass the returned http.Handler to http.ServeMux.Handle to add middleware functions that execute after pattern-based multiplexing occurs and values for path wildcards are available via http.Request.PathValue.

type MiddlewareFunc

type MiddlewareFunc func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

MiddlewareFunc specifies the call signature for middleware functions. At some point during normal execution, the middleware function must call the "next" handler function to invoke the next layer of request handling.

type MiddlewareMux

type MiddlewareMux struct {
	http.ServeMux
	// contains filtered or unexported fields
}

MiddlewareMux is an http.ServeMux with middleware functions that execute before pattern-based multiplexing occurs.

func NewMiddlewareMux

func NewMiddlewareMux(functions ...MiddlewareFunc) *MiddlewareMux

NewMiddlewareMux allocates and returns a new MiddlewareMux.

func (*MiddlewareMux) ServeHTTP

func (mux *MiddlewareMux) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP dispatches the request to each middleware function, and then to the handler whose pattern most closely matches the request URL.

type PrincipalType

type PrincipalType string
const (
	PrincipalTypeDSTSUser            PrincipalType = "dstsUser"
	PrincipalTypeAADServicePrincipal PrincipalType = "aadServicePrincipal"
)

Jump to

Keyboard shortcuts

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