HTTP API Toolkit HTTP API Toolkit
HTTP API Toolkit HTTP API Toolkit
DocFX + Singulink = ♥

Search Results for

    Method UseApiResponseHandling

    UseApiResponseHandling<TBuilder>(TBuilder)

    Configures the application to use ApiExceptionMiddleware for handling exceptions and to convert endpoint results of type IAsyncEnumerable<T> into StreamingResponse streams. T must be a reference type (value type items fail when the endpoints are built).

    Declaration
    public static TBuilder UseApiResponseHandling<TBuilder>(this TBuilder app) where TBuilder : IApplicationBuilder, IEndpointRouteBuilder
    Parameters
    Type Name Description
    TBuilder app

    The application.

    Returns
    Type Description
    TBuilder
    Type Parameters
    Name Description
    TBuilder
    Remarks

    Streaming responses are applied to every matching endpoint already mapped on the application, so this must be called after all endpoints have been mapped. Streamed items (including null items) are serialized with the application's JSON options using the endpoint's declared item type, and each record is flushed as soon as it is produced. Exceptions thrown before the first record is sent produce a regular error response via ApiExceptionMiddleware; exceptions thrown after that are converted into an error record that terminates the stream. Both are mapped using the registered IApiExceptionHandler (see AddApiExceptionHandler<THandler>(IServiceCollection)).

    Endpoints can be marked with [KeepAlivePingAttribute] to automatically send ping records whenever no item has been produced for the specified interval, keeping the response connection alive.

    © Singulink. All rights reserved.