Table of Contents

Class JsonResponse<T>

Namespace
Olve.TypeSpec
Assembly
Olve.TypeSpec.dll

Writes a generated response variant's body as JSON with the given status, through the app's JsonOptions (so the generated source-gen context serializes it). Resolving the type info there, rather than through TypedResults.Json, keeps the generated code free of reflection warnings under Native AOT.

public sealed class JsonResponse<T> : IResult

Type Parameters

T
Inheritance
JsonResponse<T>
Implements
Inherited Members

Constructors

JsonResponse(T, int)

Writes a generated response variant's body as JSON with the given status, through the app's JsonOptions (so the generated source-gen context serializes it). Resolving the type info there, rather than through TypedResults.Json, keeps the generated code free of reflection warnings under Native AOT.

public JsonResponse(T value, int status)

Parameters

value T
status int

Methods

ExecuteAsync(HttpContext)

Write an HTTP response reflecting the result.

public Task ExecuteAsync(HttpContext httpContext)

Parameters

httpContext HttpContext

The HttpContext for the current request.

Returns

Task

A task that represents the asynchronous execute operation.