From 338b59f329cd02f5f7e0ed839d00e00acb8e2c37 Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Sun, 3 Apr 2022 13:32:45 -0400 Subject: [PATCH 1/2] Split up operator""_method When wrapping calls to crow from other code bases, I have had to call `operator""_method` explicitly. Breaking it into two methods, `method_from_string` and `operator""_method` allows one to compose this code elsewhere. --- include/crow/common.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/crow/common.h b/include/crow/common.h index e7306a04f..da85d9737 100644 --- a/include/crow/common.h +++ b/include/crow/common.h @@ -279,7 +279,7 @@ namespace crow // clang-format off #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 : 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 : throw std::runtime_error("invalid http method"); } + +constexpr crow::HTTPMethod operator""_method(const char* str, size_t /*len*/) +{ + return method_from_string( str ); +} #endif // clang-format on From dcbb8a15fd00be924e6a89ccd3ac2680a2c1c2cf Mon Sep 17 00:00:00 2001 From: Darrell Wright Date: Mon, 4 Apr 2022 13:04:26 -0400 Subject: [PATCH 2/2] Update common.h Fixed extra { --- include/crow/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/crow/common.h b/include/crow/common.h index da85d9737..d9ae9b2e3 100644 --- a/include/crow/common.h +++ b/include/crow/common.h @@ -279,7 +279,7 @@ namespace crow // clang-format off #ifndef CROW_MSVC_WORKAROUND -constexpr crow::HTTPMethod method_from_string(const char* str) { +constexpr crow::HTTPMethod method_from_string(const char* str) { 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 :