Decentralised Art Server
High-performance C++ backend that exposes HTML interface and a secure REST API for managing Performative Transactions entities
Loading...
Searching...
No Matches
http_codes.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <format>
4
5
namespace
dcn::http
6
{
38
enum class
Code
39
{
40
// Unknown, specially reserved
41
Unknown
= 0,
42
43
// level 200
44
OK
= 200,
45
Created
= 201,
46
47
// LEVEL 400
48
BadRequest
= 400,
49
Unauthorized
= 401,
50
Forbidden
= 403,
51
NotFound
= 404,
52
53
// LEVEL 500
54
InternalServerError
= 500,
55
ServiceUnavailable
= 503,
56
GatewayTimeout
= 504
57
};
58
}
59
60
template
<>
61
struct
std::formatter<
dcn
::http::Code> : std::formatter<std::string> {
62
auto
format
(
dcn::http::Code
code, format_context& ctx)
const
{
63
switch
(code)
64
{
65
// level 200
66
case
dcn::http::Code::OK
:
return
formatter<string>::format(
"200 OK"
, ctx);
67
case
dcn::http::Code::Created
:
return
formatter<string>::format(
"201 Created"
, ctx);
68
69
// LEVEL 400
70
case
dcn::http::Code::BadRequest
:
return
formatter<string>::format(
"400 Bad Request"
, ctx);
71
case
dcn::http::Code::Unauthorized
:
return
formatter<string>::format(
"401 Unauthorized"
, ctx);
72
case
dcn::http::Code::Forbidden
:
return
formatter<string>::format(
"403 Forbidden"
, ctx);
73
case
dcn::http::Code::NotFound
:
return
formatter<string>::format(
"404 Not Found"
, ctx);
74
75
// LEVEL 500
76
case
dcn::http::Code::InternalServerError
:
return
formatter<string>::format(
"500 Internal Server Error"
, ctx);
77
case
dcn::http::Code::ServiceUnavailable
:
return
formatter<string>::format(
"503 Service Unavailable"
, ctx);
78
case
dcn::http::Code::GatewayTimeout
:
return
formatter<string>::format(
"504 Gateway Timeout"
, ctx);
79
80
// Unknown
81
case
dcn::http::Code::Unknown
:
return
formatter<string>::format(
"Unknown"
, ctx);
82
}
83
return
formatter<string>::format(
""
, ctx);
84
}
85
};
dcn::http
Definition
http.hpp:16
dcn::http::Code
Code
Enum to represent HTTP response status codes.
Definition
http_codes.hpp:39
dcn::http::Code::Created
@ Created
dcn::http::Code::ServiceUnavailable
@ ServiceUnavailable
dcn::http::Code::NotFound
@ NotFound
dcn::http::Code::Forbidden
@ Forbidden
dcn::http::Code::Unknown
@ Unknown
dcn::http::Code::BadRequest
@ BadRequest
dcn::http::Code::GatewayTimeout
@ GatewayTimeout
dcn::http::Code::Unauthorized
@ Unauthorized
dcn::http::Code::OK
@ OK
dcn::http::Code::InternalServerError
@ InternalServerError
dcn
Definition
decentralised_art.hpp:30
std::formatter< dcn::http::Code >::format
auto format(dcn::http::Code code, format_context &ctx) const
Definition
http_codes.hpp:62
src
http
include
http_codes.hpp
Generated by
1.9.8