blob: 33dd5690dcecf5be0fab5e0c8b3b21a6682bba9a [file] [log] [blame]
#pragma once
#include <boost/beast/http/verb.hpp>
#include <optional>
#include <string_view>
enum class HttpVerb
{
Delete = 0,
Get,
Head,
Options,
Patch,
Post,
Put,
Max,
};
inline std::optional<HttpVerb> httpVerbFromBoost(boost::beast::http::verb bv)
{
switch (bv)
{
case boost::beast::http::verb::delete_:
return HttpVerb::Delete;
case boost::beast::http::verb::get:
return HttpVerb::Get;
case boost::beast::http::verb::head:
return HttpVerb::Head;
case boost::beast::http::verb::options:
return HttpVerb::Options;
case boost::beast::http::verb::patch:
return HttpVerb::Patch;
case boost::beast::http::verb::post:
return HttpVerb::Post;
case boost::beast::http::verb::put:
return HttpVerb::Put;
default:
return std::nullopt;
}
return std::nullopt;
}
inline std::string_view httpVerbToString(HttpVerb verb)
{
switch (verb)
{
case HttpVerb::Delete:
return "DELETE";
case HttpVerb::Get:
return "GET";
case HttpVerb::Head:
return "HEAD";
case HttpVerb::Patch:
return "PATCH";
case HttpVerb::Post:
return "POST";
case HttpVerb::Put:
return "PUT";
case HttpVerb::Options:
return "OPTIONS";
case HttpVerb::Max:
return "";
}
// Should never reach here
return "";
}