Path: redb-route/redb.Route.Controllers/IControllerActionFilter.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Controllers/IControllerActionFilter.cs ---- using redb.Route.Abstractions; namespace redb.Route.Controllers; /// /// Per-action invocation context passed to s. /// All mutable fields are populated by /// before filters are invoked. /// public sealed class ControllerActionContext { /// The current message exchange. public IExchange Exchange { get; } /// Resolved controller action descriptor. public ControllerAction Action { get; } /// Route parameters extracted from the path. public IReadOnlyDictionary RouteParams { get; } /// Resolved positional argument values for the action method. public object?[] Arguments { get; internal set; } = Array.Empty(); /// Action result (set after invocation, before ). public object? Result { get; internal set; } /// Exception thrown by the action (if any). public Exception? Exception { get; internal set; } /// HTTP-style status code written to the response. public int StatusCode { get; internal set; } /// Wall-clock duration of the action invocation (excluding filter Before phase). public TimeSpan Elapsed { get; internal set; } /// Free-form items bag for filter-to-filter communication within a single invocation. public IDictionary Items { get; } = new Dictionary(StringComparer.Ordinal); public ControllerActionContext( IExchange exchange, ControllerAction action, IReadOnlyDictionary routeParams) { Exchange = exchange; Action = action; RouteParams = routeParams; } } /// /// Optional filter SPI invoked around every controller action by /// . Filters are resolved once at /// dispatcher construction time and ordered by ascending. /// /// runs in ascending order, /// runs in reverse (descending) order — classic onion model. /// /// /// Filters MUST be tolerant: throwing from a filter is logged but does not propagate /// to the action result. Use this for cross-cutting concerns like auditing, metrics, /// correlation IDs. /// /// public interface IControllerActionFilter { /// Lower values run first in , last in . int Order { get; } /// Invoked before the action method is called. Task BeforeAsync(ControllerActionContext context, CancellationToken ct); /// /// Invoked after the action method completes (whether success or failure). /// Inspect to detect failures. /// Task AfterAsync(ControllerActionContext context, CancellationToken ct); }