| | | 1 | | namespace ArturRios.Util.Http; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Provides common HTTP status code constants and grouped collections for convenience. |
| | | 5 | | /// </summary> |
| | | 6 | | public static class HttpStatusCodes |
| | | 7 | | { |
| | | 8 | | /// <summary>HTTP 200 - OK.</summary> |
| | | 9 | | public const int Ok = 200; |
| | | 10 | | /// <summary>HTTP 201 - Created.</summary> |
| | | 11 | | public const int Created = 201; |
| | | 12 | | /// <summary>HTTP 204 - No Content.</summary> |
| | | 13 | | public const int NoContent = 204; |
| | | 14 | | |
| | | 15 | | /// <summary>HTTP 400 - Bad Request.</summary> |
| | | 16 | | public const int BadRequest = 400; |
| | | 17 | | /// <summary>HTTP 401 - Unauthorized.</summary> |
| | | 18 | | public const int Unauthorized = 401; |
| | | 19 | | /// <summary>HTTP 403 - Forbidden.</summary> |
| | | 20 | | public const int Forbidden = 403; |
| | | 21 | | /// <summary>HTTP 404 - Not Found.</summary> |
| | | 22 | | public const int NotFound = 404; |
| | | 23 | | |
| | | 24 | | /// <summary>HTTP 500 - Internal Server Error.</summary> |
| | | 25 | | public const int InternalServerError = 500; |
| | | 26 | | /// <summary>HTTP 501 - Not Implemented.</summary> |
| | | 27 | | public const int NotImplemented = 501; |
| | | 28 | | /// <summary>HTTP 502 - Bad Gateway.</summary> |
| | | 29 | | public const int BadGateway = 502; |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Group containing success status codes (2xx). |
| | | 33 | | /// </summary> |
| | 16 | 34 | | public static int[] Success => [Ok, Created, NoContent]; |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// Group containing client error status codes (4xx). |
| | | 38 | | /// </summary> |
| | 17 | 39 | | public static int[] ClientError => [BadRequest, Unauthorized, Forbidden, NotFound]; |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Group containing server error status codes (5xx). |
| | | 43 | | /// </summary> |
| | 16 | 44 | | public static int[] ServerError => [InternalServerError, NotImplemented, BadGateway]; |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Convenience property containing all supported status codes. |
| | | 48 | | /// </summary> |
| | 11 | 49 | | public static int[] All => [..Success, ..ClientError, ..ServerError]; |
| | | 50 | | } |