Merge pull request #383 from beached/patch-1

Split up operator""_method
This commit is contained in:
Farook Al-Sammarraie 2022-04-04 20:37:14 +03:00 committed by GitHub
commit 71c01a9bbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -279,7 +279,7 @@ namespace crow
// clang-format off // clang-format off
#ifndef CROW_MSVC_WORKAROUND #ifndef CROW_MSVC_WORKAROUND
constexpr crow::HTTPMethod operator"" _method(const char* str, size_t /*len*/) constexpr crow::HTTPMethod method_from_string(const char* str)
{ {
return crow::black_magic::is_equ_p(str, "GET", 3) ? crow::HTTPMethod::Get : return crow::black_magic::is_equ_p(str, "GET", 3) ? crow::HTTPMethod::Get :
crow::black_magic::is_equ_p(str, "DELETE", 6) ? crow::HTTPMethod::Delete : crow::black_magic::is_equ_p(str, "DELETE", 6) ? crow::HTTPMethod::Delete :
@ -324,5 +324,10 @@ constexpr crow::HTTPMethod operator"" _method(const char* str, size_t /*len*/)
crow::black_magic::is_equ_p(str, "SOURCE", 6) ? crow::HTTPMethod::Source : crow::black_magic::is_equ_p(str, "SOURCE", 6) ? crow::HTTPMethod::Source :
throw std::runtime_error("invalid http method"); throw std::runtime_error("invalid http method");
} }
constexpr crow::HTTPMethod operator""_method(const char* str, size_t /*len*/)
{
return method_from_string( str );
}
#endif #endif
// clang-format on // clang-format on