Class ApiResponse
Unified API error/success response helpers for all Tsak controllers.
Uses from redb.Route.Core for consistency.
public static class ApiResponse
Inheritance
Methods
BadRequest(IExchange, string)
400 Bad Request.
public static void BadRequest(IExchange exchange, string message)
Conflict(IExchange, string)
409 Conflict.
public static void Conflict(IExchange exchange, string message)
Created(IExchange, object?)
Write a 201 Created response.
public static void Created(IExchange exchange, object? body = null)
Error(IExchange, int, string, string)
Write an error response using the standard ControllerErrorResponse format.
public static void Error(IExchange exchange, int statusCode, string error, string message)
Forbidden(IExchange, string)
403 Forbidden.
public static void Forbidden(IExchange exchange, string message = "Forbidden")
InternalError(IExchange, string)
500 Internal Server Error.
public static void InternalError(IExchange exchange, string message = "Internal server error")
NoContent(IExchange)
Write a 204 No Content response.
public static void NoContent(IExchange exchange)
NotFound(IExchange, string)
404 Not Found.
public static void NotFound(IExchange exchange, string message)
Ok(IExchange, object?)
Write a success response to exchange.Out.
public static void Ok(IExchange exchange, object? body = null)
Respond(IExchange, int, object)
Write a JSON body with any status code: an answer whose status code is part of the answer.
public static void Respond(IExchange exchange, int statusCode, object body)
TooManyRequests(IExchange, string)
429 Too Many Requests.
public static void TooManyRequests(IExchange exchange, string message = "Too many requests")
Unauthorized(IExchange, string)
401 Unauthorized.
public static void Unauthorized(IExchange exchange, string message = "Unauthorized")