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
responseHttpResponseThe HTTP response to write to.
statusCodeintThe status code of the response.
valueobjectThe object to serialize as JSON.
serializerOptionsJsonSerializerOptionsThe JSON serializer options.
cancellationTokenCancellationTokenThe 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
responseHttpResponseThe HTTP response to write to.
statusCodeintThe status code of the response.
valueobjectThe object to serialize as JSON.
cancellationTokenCancellationTokenThe 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
responseHttpResponseThe HTTP response to write to.
statusCodeHttpStatusCodeThe status code of the response.
valueobjectThe object to serialize as JSON.
serializerOptionsJsonSerializerOptionsThe JSON serializer options.
cancellationTokenCancellationTokenThe 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
responseHttpResponseThe HTTP response to write to.
statusCodeHttpStatusCodeThe status code of the response.
valueobjectThe object to serialize as JSON.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task
An asynchronous operation.