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_method.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <format>
4#include <string>
5
6namespace dcn::http
7{
30 enum class Method
31 {
32 //Unknown, specially reserved
33 Unknown = 0,
34
35 GET,
36 HEAD,
37 PUT,
38 DEL, //DELETE collides with macro definition in winnt.h ...
39 POST,
41 };
42}
43
44namespace dcn::parse
45{
53 http::Method parseMethodFromString(const std::string & method);
54}
55
56template <>
57struct std::formatter<dcn::http::Method> : std::formatter<std::string> {
58
59 auto format(dcn::http::Method method, format_context& ctx) const {
60 switch(method)
61 {
62 case dcn::http::Method::GET: return formatter<string>::format("GET", ctx);
63 case dcn::http::Method::HEAD: return formatter<string>::format("HEAD", ctx);
64 case dcn::http::Method::PUT: return formatter<string>::format("PUT", ctx);
65 case dcn::http::Method::DEL: return formatter<string>::format("DELETE", ctx);
66 case dcn::http::Method::POST: return formatter<string>::format("POST", ctx);
67 case dcn::http::Method::OPTIONS: return formatter<string>::format("OPTIONS", ctx);
68
69 // Unknown
70 case dcn::http::Method::Unknown: return formatter<string>::format("Unknown", ctx);
71 }
72 return formatter<string>::format("", ctx);
73 }
74};
Definition http.hpp:16
Method
Enum to represent the request method.
Definition http_method.hpp:31
Definition auth.hpp:34
http::Method parseMethodFromString(const std::string &method)
Parse the given string to a http::Method.
Definition http_method.cpp:5
Definition decentralised_art.hpp:30
auto format(dcn::http::Method method, format_context &ctx) const
Definition http_method.hpp:59