SimpleREST.NET 0.1
A simple and minimal api framework for .net base on Express.js
Loading...
Searching...
No Matches
StatusCode.cs
Go to the documentation of this file.
1using System;
2
3namespace SimpleRest.Api;
4
5public class StatusCode : IStatusCode
6{
7 public int Code { get; private set; }
8 public string Name { get; private set; }
9 public string Message { get; private set; }
10 public string Severity { get; private set; }
11
12 public StatusCode(int code, string name = "", string message = "", string severity = "")
13 {
14 Code = code;
15 Name = name;
16 Message = message;
17 Severity = severity;
18 }
19
20 public static readonly StatusCode Success = new StatusCode(
21 200,
22 "OK",
23 "Operation completed successfully",
24 "Info"
25 );
26 public static readonly StatusCode BadRequest = new StatusCode(
27 400,
28 "BadRequest",
29 "Bad request",
30 "Warning"
31 );
32 public static readonly StatusCode Unauthorized = new StatusCode(
33 401,
34 "Unauthorized",
35 "Unauthorized access",
36 "Error"
37 );
38 public static readonly StatusCode NotFound = new StatusCode(
39 404,
40 "NotFound",
41 "Resource not found",
42 "Warning"
43 );
44 public static readonly StatusCode InternalServerError = new StatusCode(
45 500,
46 "ServerError",
47 "Internal server error",
48 "Critical"
49 );
50
51 public override string ToString() => $"{Code} {Name}: {Message} (Severity: {Severity})";
52}
static readonly StatusCode NotFound
Definition StatusCode.cs:38
static readonly StatusCode InternalServerError
Definition StatusCode.cs:44
static readonly StatusCode BadRequest
Definition StatusCode.cs:26
static readonly StatusCode Success
Definition StatusCode.cs:20
StatusCode(int code, string name="", string message="", string severity="")
Definition StatusCode.cs:12
override string ToString()
static readonly StatusCode Unauthorized
Definition StatusCode.cs:32