Table of Contents

Class HttpResponseExtensions

Namespace
MADE.Web.Extensions
Assembly
MADE.Web.dll

Defines a collection of extensions for a HttpResponse object.

public static class HttpResponseExtensions
Inheritance
HttpResponseExtensions
Inherited Members

Methods

WriteJsonAsync(HttpResponse, int, object, JsonSerializerOptions?, CancellationToken)

Writes an object value as JSON to the specified response.

public static Task WriteJsonAsync(this HttpResponse response, int statusCode, object value, JsonSerializerOptions? serializerOptions, CancellationToken cancellationToken = default)

Parameters

response HttpResponse

The HTTP response to write to.

statusCode int

The status code of the response.

value object

The object to serialize as JSON.

serializerOptions JsonSerializerOptions

The JSON serializer options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

An asynchronous operation.

WriteJsonAsync(HttpResponse, int, object, CancellationToken)

Writes an object value as JSON to the specified response.

public static Task WriteJsonAsync(this HttpResponse response, int statusCode, object value, CancellationToken cancellationToken = default)

Parameters

response HttpResponse

The HTTP response to write to.

statusCode int

The status code of the response.

value object

The object to serialize as JSON.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

An asynchronous operation.

WriteJsonAsync(HttpResponse, HttpStatusCode, object, JsonSerializerOptions?, CancellationToken)

Writes an object value as JSON to the specified response.

public static Task WriteJsonAsync(this HttpResponse response, HttpStatusCode statusCode, object value, JsonSerializerOptions? serializerOptions, CancellationToken cancellationToken = default)

Parameters

response HttpResponse

The HTTP response to write to.

statusCode HttpStatusCode

The status code of the response.

value object

The object to serialize as JSON.

serializerOptions JsonSerializerOptions

The JSON serializer options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

An asynchronous operation.

WriteJsonAsync(HttpResponse, HttpStatusCode, object, CancellationToken)

Writes an object value as JSON to the specified response.

public static Task WriteJsonAsync(this HttpResponse response, HttpStatusCode statusCode, object value, CancellationToken cancellationToken = default)

Parameters

response HttpResponse

The HTTP response to write to.

statusCode HttpStatusCode

The status code of the response.

value object

The object to serialize as JSON.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

An asynchronous operation.