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_headers.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <format>
4
#include <string>
5
#include <vector>
6
7
namespace
dcn::http
8
{
14
enum class
Header
15
{
16
// Unknown, specially reserved
17
Unknown
= 0,
18
19
Accept
,
20
AccessControlAllowOrigin
,
21
AccessControlAllowMethods
,
22
AccessControlAllowHeaders
,
23
Authorization
,
24
25
Connection
,
26
ContentEncoding
,
27
ContentLength
,
28
ContentType
,
29
30
Cookie
,
31
Date
,
32
Expect
,
33
34
SetCookie
35
};
36
42
using
HeadersList
= std::vector<std::pair<Header, std::string>>;
43
}
44
45
namespace
dcn::parse
46
{
52
http::Header
parseHeaderFromString
(
const
std::string &
header_str
);
53
}
54
55
template
<>
56
struct
std::formatter<
dcn
::http::Header> : std::formatter<std::string> {
57
auto
format
(
dcn::http::Header
header, format_context& ctx)
const
{
58
switch
(header)
59
{
60
// A
61
case
dcn::http::Header::Accept
:
return
formatter<string>::format(
"Accept"
, ctx);
62
case
dcn::http::Header::AccessControlAllowOrigin
:
return
formatter<string>::format(
"Access-Control-Allow-Origin"
, ctx);
63
case
dcn::http::Header::AccessControlAllowMethods
:
return
formatter<string>::format(
"Access-Control-Allow-Methods"
, ctx);
64
case
dcn::http::Header::AccessControlAllowHeaders
:
return
formatter<string>::format(
"Access-Control-Allow-Headers"
, ctx);
65
case
dcn::http::Header::Authorization
:
return
formatter<string>::format(
"Authorization"
, ctx);
66
67
// B
68
69
// C
70
case
dcn::http::Header::Connection
:
return
formatter<string>::format(
"Connection"
, ctx);
71
case
dcn::http::Header::ContentEncoding
:
return
formatter<string>::format(
"Content-Encoding"
, ctx);
72
case
dcn::http::Header::ContentLength
:
return
formatter<string>::format(
"Content-Length"
, ctx);
73
case
dcn::http::Header::ContentType
:
return
formatter<string>::format(
"Content-Type"
, ctx);
74
case
dcn::http::Header::Cookie
:
return
formatter<string>::format(
"Cookie"
, ctx);
75
76
// D
77
case
dcn::http::Header::Date
:
return
formatter<string>::format(
"Date"
, ctx);
78
79
// S
80
case
dcn::http::Header::SetCookie
:
return
formatter<string>::format(
"Set-Cookie"
, ctx);
81
82
83
// Unknown
84
case
dcn::http::Header::Unknown
:
return
formatter<string>::format(
"Unknown"
, ctx);
85
}
86
return
formatter<string>::format(
""
, ctx);
87
}
88
};
89
90
template
<>
91
struct
std::formatter<
dcn
::http::HeadersList> : std::formatter<std::string> {
92
auto
format
(
dcn::http::HeadersList
headers_list, format_context& ctx)
const
{
93
std::string headers_str =
""
;
94
for
(
const
auto
& [header, header_value] : headers_list)
95
{
96
headers_str += std::format(
"{}: {}\n"
, header, header_value);
97
}
98
return
formatter<string>::format(headers_str, ctx);
99
}
100
};
dcn::http
Definition
http.hpp:16
dcn::http::Code::Unknown
@ Unknown
dcn::http::Header
Header
Enum of HTTP headers as defined by the standard This enum contains the most commonly used HTTP header...
Definition
http_headers.hpp:15
dcn::http::Header::ContentLength
@ ContentLength
dcn::http::Header::SetCookie
@ SetCookie
dcn::http::Header::AccessControlAllowMethods
@ AccessControlAllowMethods
dcn::http::Header::Date
@ Date
dcn::http::Header::Cookie
@ Cookie
dcn::http::Header::Expect
@ Expect
dcn::http::Header::Unknown
@ Unknown
dcn::http::Header::ContentEncoding
@ ContentEncoding
dcn::http::Header::Authorization
@ Authorization
dcn::http::Header::ContentType
@ ContentType
dcn::http::Header::AccessControlAllowOrigin
@ AccessControlAllowOrigin
dcn::http::Header::Connection
@ Connection
dcn::http::Header::Accept
@ Accept
dcn::http::Header::AccessControlAllowHeaders
@ AccessControlAllowHeaders
dcn::http::HeadersList
std::vector< std::pair< Header, std::string > > HeadersList
A list of headers A HeadersList is a vector of pairs, where the first element of the pair is a Header...
Definition
http_headers.hpp:42
dcn::parse
Definition
auth.hpp:34
dcn::parse::parseHeaderFromString
http::Header parseHeaderFromString(const std::string &header_str)
Parse a header string to a Header enum.
Definition
http_headers.cpp:5
dcn
Definition
decentralised_art.hpp:30
dcn::RouteArgRequirement::optional
@ optional
std::formatter< dcn::http::Header >::format
auto format(dcn::http::Header header, format_context &ctx) const
Definition
http_headers.hpp:57
std::formatter< dcn::http::HeadersList >::format
auto format(dcn::http::HeadersList headers_list, format_context &ctx) const
Definition
http_headers.hpp:92
src
http
include
http_headers.hpp
Generated by
1.9.8