{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package middleware\n\nPackage middleware provides HTTP middleware for the platform abstraction layer.\n\n## Constants\n\n```go\nconst (\n\t// RoleContextKey is the context key for the TierRole extracted from the request.\n\tRoleContextKey contextKey = \"platform_role\"\n)\n```\n\n## Functions\n\n```go\nfunc RoleFromContext(ctx context.Context) (platform.TierRole, bool)\n```\nRoleFromContext extracts the TierRole from the request context.\n\n```go\nfunc TierFromPath(path string) (platform.Tier, error)\n```\nTierFromPath extracts a Tier from a URL path. It looks for segments matching \"tier1\", \"tier2\", or \"tier3\" in paths like \"/api/v1/platform/tier1/resources\".\n\n```go\nfunc WithRole(ctx context.Context, role platform.TierRole) context.Context\n```\nWithRole returns a new context with the given TierRole set.\n\n## Types\n\n```go\ntype TierBoundaryMiddleware struct {\n\t// contains filtered or unexported fields\n}\n```\nTierBoundaryMiddleware enforces tier-based access control on HTTP requests. It extracts the role from the request context and the target tier from the URL path, then delegates authorization to a TierAuthorizer.\n\n```go\nfunc NewTierBoundaryMiddleware(authorizer platform.TierAuthorizer) *TierBoundaryMiddleware\n```\nNewTierBoundaryMiddleware creates a TierBoundaryMiddleware backed by the given TierAuthorizer.\n\n```go\nfunc (m *TierBoundaryMiddleware) Wrap(next http.Handler) http.Handler\n```\nWrap returns an http.Handler that performs tier boundary checks before delegating to next. If the request lacks a role in its context, a 401 response is returned. If authorization fails, a 403 response with a structured JSON error body is returned.\n\n","path":"github.com/GoCodeAlone/workflow/platform/middleware","name":"middleware","synopsis":"Package middleware provides HTTP middleware for the platform abstraction layer.","isRedistributable":true}
