Skip to content

Requests

Ian Johnson edited this page Oct 26, 2022 · 1 revision

Requests

All requests in hardened go through a middleware pipeline, then a request filter pipeline. Both types of filter use the same interfaces, the difference being where they are applied in the pipeline

IExecutionChain

public interface IExecutionChain
{
    /// <summary>
    /// execute next action in chain
    /// </summary>
    /// <returns></returns>
    Task Next();

    /// <summary>
    /// Execution context
    /// </summary>
    IExecutionContext Context { get; }

    /// <summary>
    /// Copy execution chain so that it can be executed multiple times
    /// IExecutionContext will be copied as well if a new context is not provided
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    IExecutionChain Fork(IExecutionContext context);

    /// <summary>
    /// True if the chain is on it's last filter.
    /// </summary>
    bool IsLastFilter { get; }
}

IExecutionContext

public interface IExecutionContext : ICloneable
{
    /// <summary>
    /// Root service provider for the application
    /// </summary>
    IServiceProvider RootServiceProvider { get; }

    /// <summary>
    /// Set of request services
    /// </summary>
    IKnownServices KnownServices { get; }

    /// <summary>
    /// Service provider that is created/used for the life of the request
    /// </summary>
    IServiceProvider RequestServices { get; }

    /// <summary>
    /// Request parameters
    /// </summary>
    IExecutionRequest Request { get; }

    /// <summary>
    /// Response output
    /// </summary>
    IExecutionResponse Response { get; }

    /// <summary>
    /// Handler for the call, will be null for middleware handlers
    /// </summary>
    object? HandlerInstance { get; set; }

    /// <summary>
    /// Get information about the 
    /// </summary>
    IExecutionRequestHandlerInfo? HandlerInfo { get; set; }

    /// <summary>
    /// Default output function, used to assign template
    /// </summary>
    DefaultOutputFunc? DefaultOutput { get; set; }

    /// <summary>
    /// Metric logger for the request
    /// </summary>
    IMetricLogger RequestMetrics { get; }

    /// <summary>
    /// Request StartTime
    /// </summary>
    MachineTimestamp StartTime { get; }

    /// <summary>
    /// Cancellation token, only applicable on some platforms
    /// </summary>
    CancellationToken CancellationToken { get; }
}

Middleware

Request Filter

Clone this wiki locally