# Interface IHubOperationBuilder OptimaJet.Workflow.Api.Configuration.IHubOperationBuilder Registers callbacks for client invocations of one library-owned hub. Namespace: [OptimaJet.Workflow.Api.Configuration](https://api.workflowengine.io/web-api/OptimaJet.Workflow.Api.Configuration/) ```csharp public interface IHubOperationBuilder ``` ## Methods `IHubOperationBuilder OnBefore(Func> callback)` Adds argument preparation. Null continues; a result skips remaining before/authorization callbacks and the method, then runs OnAfter. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func` | The preparation callback. | ### Returns | Type | Description | | --- | --- | | `IHubOperationBuilder` | This builder. | ### Remarks Only this stage permits ReplaceArguments. Transport binding and ASP.NET authorization run first. `IHubOperationBuilder OnAuthorize(Func> callback)` Adds authorization over the final arguments. The first false produces a failed completion and skips remaining authorization callbacks and the method. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func` | The authorization callback. | ### Returns | Type | Description | | --- | --- | | `IHubOperationBuilder` | This builder. | ### Remarks Runs even when built-in security is disabled. Do not mutate arguments in this stage. `IHubOperationBuilder OnAfterSuccess(Func> callback)` Adds a transformation of the original method's non-null result, preserving its declared payload type. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func` | The result transformation. | ### Returns | Type | Description | | --- | --- | | `IHubOperationBuilder` | This builder. | ### Remarks Skipped for void/null returns, failures, short circuits and exception fallbacks. A stream is one return object; its items are outside this pipeline. `IHubOperationBuilder OnAfter(Func> callback)` Adds a transformation of the final completion, including short circuits, authorization denial and recovered exceptions. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func` | The transformation, which must return a non-null completion. | ### Returns | Type | Description | | --- | --- | | `IHubOperationBuilder` | This builder. | `IHubOperationBuilder OnException(Func> callback)` Adds exception recovery. Null passes the original exception to the next callback; a completion handles it. ### Parameters | Name | Type | Description | | --- | --- | --- | | `callback` | `Func` | The recovery callback. | ### Returns | Type | Description | | --- | --- | | `IHubOperationBuilder` | This builder. | ### Remarks Covers callbacks and method invocation, not binding, serialization, connection lifecycle or stream enumeration. Connection cancellation and protected tenant/process failures bypass recovery. Unhandled errors preserve their stack. Recovery failures do not re-enter recovery. A fallback before OnAfter passes through it once; a fallback for an OnAfter error is sent directly. ## Remarks Stages run in order: OnBefore, OnAuthorize, method, OnAfterSuccess, OnAfter. Each stage preserves registration order. Repeated selection shares the builder; freezing rejects further changes. Callbacks wrap method invocation, not connection lifecycle, outgoing events, or stream enumeration. Resolve scoped dependencies from the invocation context's Services. [Previous HubOperationResult](https://api.workflowengine.io/web-api/OptimaJet.Workflow.Api.Configuration/HubOperationResult/) [Next IHubOperationContext](https://api.workflowengine.io/web-api/OptimaJet.Workflow.Api.Configuration/IHubOperationContext/)