Deprecate the "" operator, and isEqP

While a cool example of how to do string matching in constexpr space,
the set of verbs available to HTTP has been fixed for a very long time.

This was ported over to beast a while back, but we kept the API for....
mediocre reasons of backward compatibility.  Remove that, and delete the
now unused code.

Tested: Built and loaded on a Witherspoon. Validator passes.

Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Change-Id: Iaf048e196f9b6e71983189877203bf80390df286
Signed-off-by: James Feist <james.feist@linux.intel.com>
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/http/common.h b/http/common.h
index 47df7e6..77db63c 100644
--- a/http/common.h
+++ b/http/common.h
@@ -111,23 +111,3 @@
 }
 
 } // namespace crow
-
-constexpr boost::beast::http::verb operator"" _method(const char* str,
-                                                      size_t /*len*/)
-{
-    using verb = boost::beast::http::verb;
-    // clang-format off
-  return
-    crow::black_magic::isEquP(str, "GET", 3) ? verb::get :
-    crow::black_magic::isEquP(str, "DELETE", 6) ? verb::delete_ :
-    crow::black_magic::isEquP(str, "HEAD", 4) ? verb::head :
-    crow::black_magic::isEquP(str, "POST", 4) ? verb::post :
-    crow::black_magic::isEquP(str, "PUT", 3) ? verb::put :
-    crow::black_magic::isEquP(str, "OPTIONS", 7) ? verb::options :
-    crow::black_magic::isEquP(str, "CONNECT", 7) ? verb::connect :
-    crow::black_magic::isEquP(str, "TRACE", 5) ? verb::trace :
-    crow::black_magic::isEquP(str, "PATCH", 5) ? verb::patch :
-    crow::black_magic::isEquP(str, "PURGE", 5) ? verb::purge :
-    throw std::runtime_error("invalid http method");
-    // clang-format on
-}
diff --git a/http/utility.h b/http/utility.h
index 4792f6f..8254091 100644
--- a/http/utility.h
+++ b/http/utility.h
@@ -78,16 +78,6 @@
                                                  : isValid(s, i + 1, f);
 }
 
-constexpr bool isEquP(const char* a, const char* b, unsigned n)
-{
-    return *a == 0 && *b == 0 && n == 0
-               ? true
-               : (*a == 0 || *b == 0)
-                     ? false
-                     : n == 0 ? true
-                              : *a != *b ? false : isEquP(a + 1, b + 1, n - 1);
-}
-
 constexpr bool isEquN(ConstStr a, unsigned ai, ConstStr b, unsigned bi,
                       unsigned n)
 {
diff --git a/include/authorization.hpp b/include/authorization.hpp
index 9074377..8237bc4 100644
--- a/include/authorization.hpp
+++ b/include/authorization.hpp
@@ -140,7 +140,7 @@
     }
 #ifndef BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION
     // RFC7231 defines methods that need csrf protection
-    if (req.method() != "GET"_method)
+    if (req.method() != boost::beast::http::verb::get)
     {
         std::string_view csrf = req.getHeaderValue("X-XSRF-TOKEN");
         // Make sure both tokens are filled
@@ -167,7 +167,7 @@
 static bool isOnWhitelist(const crow::Request& req)
 {
     // it's allowed to GET root node without authentication
-    if ("GET"_method == req.method())
+    if (boost::beast::http::verb::get == req.method())
     {
         if (req.url == "/redfish/v1" || req.url == "/redfish/v1/" ||
             req.url == "/redfish" || req.url == "/redfish/" ||
@@ -184,7 +184,7 @@
 
     // it's allowed to POST on session collection & login without
     // authentication
-    if ("POST"_method == req.method())
+    if (boost::beast::http::verb::post == req.method())
     {
         if ((req.url == "/redfish/v1/SessionService/Sessions") ||
             (req.url == "/redfish/v1/SessionService/Sessions/") ||
diff --git a/include/ibm/management_console_rest.hpp b/include/ibm/management_console_rest.hpp
index a7ac761..525c27d 100644
--- a/include/ibm/management_console_rest.hpp
+++ b/include/ibm/management_console_rest.hpp
@@ -253,19 +253,19 @@
 inline void handleFileUrl(const crow::Request& req, crow::Response& res,
                           const std::string& fileID)
 {
-    if (req.method() == "PUT"_method)
+    if (req.method() == boost::beast::http::verb::put)
     {
         handleFilePut(req, res, fileID);
         res.end();
         return;
     }
-    if (req.method() == "GET"_method)
+    if (req.method() == boost::beast::http::verb::get)
     {
         handleFileGet(res, fileID);
         res.end();
         return;
     }
-    if (req.method() == "DELETE"_method)
+    if (req.method() == boost::beast::http::verb::delete_)
     {
         handleFileDelete(res, fileID);
         res.end();
@@ -532,7 +532,7 @@
     // allowed only for admin
     BMCWEB_ROUTE(app, "/ibm/v1/")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("GET"_method)(
+        .methods(boost::beast::http::verb::get)(
             [](const crow::Request& req, crow::Response& res) {
                 res.jsonValue["@odata.type"] =
                     "#ibmServiceRoot.v1_0_0.ibmServiceRoot";
@@ -548,7 +548,7 @@
 
     BMCWEB_ROUTE(app, "/ibm/v1/Host/ConfigFiles")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("GET"_method)(
+        .methods(boost::beast::http::verb::get)(
             [](const crow::Request& req, crow::Response& res) {
                 handleConfigFileList(res);
             });
@@ -556,27 +556,28 @@
     BMCWEB_ROUTE(app,
                  "/ibm/v1/Host/ConfigFiles/Actions/FileCollection.DeleteAll")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("POST"_method)(
+        .methods(boost::beast::http::verb::post)(
             [](const crow::Request& req, crow::Response& res) {
                 deleteConfigFiles(res);
             });
 
     BMCWEB_ROUTE(app, "/ibm/v1/Host/ConfigFiles/<path>")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("PUT"_method, "GET"_method, "DELETE"_method)(
+        .methods(boost::beast::http::verb::put, boost::beast::http::verb::get,
+                 boost::beast::http::verb::delete_)(
             [](const crow::Request& req, crow::Response& res,
                const std::string& path) { handleFileUrl(req, res, path); });
 
     BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("GET"_method)(
+        .methods(boost::beast::http::verb::get)(
             [](const crow::Request& req, crow::Response& res) {
                 getLockServiceData(res);
             });
 
     BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.AcquireLock")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("POST"_method)(
+        .methods(boost::beast::http::verb::post)(
             [](const crow::Request& req, crow::Response& res) {
                 std::vector<nlohmann::json> body;
                 if (!redfish::json_util::readJson(req, res, "Request", body))
@@ -590,8 +591,8 @@
             });
     BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.ReleaseLock")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods(
-            "POST"_method)([](const crow::Request& req, crow::Response& res) {
+        .methods(boost::beast::http::verb::post)([](const crow::Request& req,
+                                                    crow::Response& res) {
             std::string type;
             std::vector<uint32_t> listTransactionIds;
 
@@ -620,7 +621,7 @@
         });
     BMCWEB_ROUTE(app, "/ibm/v1/HMC/LockService/Actions/LockService.GetLockList")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("POST"_method)(
+        .methods(boost::beast::http::verb::post)(
             [](const crow::Request& req, crow::Response& res) {
                 ListOfSessionIds listSessionIds;
 
diff --git a/include/image_upload.hpp b/include/image_upload.hpp
index 64adccd..c1ec682 100644
--- a/include/image_upload.hpp
+++ b/include/image_upload.hpp
@@ -114,15 +114,15 @@
 {
     BMCWEB_ROUTE(app, "/upload/image/<str>")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("POST"_method,
-                 "PUT"_method)([](const crow::Request& req, crow::Response& res,
-                                  const std::string& filename) {
-            uploadImageHandler(req, res, filename);
-        });
+        .methods(boost::beast::http::verb::post, boost::beast::http::verb::put)(
+            [](const crow::Request& req, crow::Response& res,
+               const std::string& filename) {
+                uploadImageHandler(req, res, filename);
+            });
 
     BMCWEB_ROUTE(app, "/upload/image")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("POST"_method, "PUT"_method)(
+        .methods(boost::beast::http::verb::post, boost::beast::http::verb::put)(
             [](const crow::Request& req, crow::Response& res) {
                 uploadImageHandler(req, res, "");
             });
diff --git a/include/login_routes.hpp b/include/login_routes.hpp
index 346ab89..91acda7 100644
--- a/include/login_routes.hpp
+++ b/include/login_routes.hpp
@@ -28,8 +28,8 @@
         "auth routes");
 
     BMCWEB_ROUTE(app, "/login")
-        .methods(
-            "POST"_method)([](const crow::Request& req, crow::Response& res) {
+        .methods(boost::beast::http::verb::post)([](const crow::Request& req,
+                                                    crow::Response& res) {
             std::string_view contentType = req.getHeaderValue("content-type");
             std::string_view username;
             std::string_view password;
@@ -196,7 +196,7 @@
         });
 
     BMCWEB_ROUTE(app, "/logout")
-        .methods("POST"_method)(
+        .methods(boost::beast::http::verb::post)(
             [](const crow::Request& req, crow::Response& res) {
                 auto& session = req.session;
                 if (session != nullptr)
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index ea7dc95..c41a568 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -2013,7 +2013,7 @@
         objectPath = objectPath.substr(0, attrPosition);
     }
 
-    if (req.method() == "POST"_method)
+    if (req.method() == boost::beast::http::verb::post)
     {
         constexpr const char* actionSeperator = "/action/";
         size_t actionPosition = objectPath.find(actionSeperator);
@@ -2027,7 +2027,7 @@
             return;
         }
     }
-    else if (req.method() == "GET"_method)
+    else if (req.method() == boost::beast::http::verb::get)
     {
         if (boost::ends_with(objectPath, "/enumerate"))
         {
@@ -2056,12 +2056,12 @@
         }
         return;
     }
-    else if (req.method() == "PUT"_method)
+    else if (req.method() == boost::beast::http::verb::put)
     {
         handlePut(req, res, objectPath, destProperty);
         return;
     }
-    else if (req.method() == "DELETE"_method)
+    else if (req.method() == boost::beast::http::verb::delete_)
     {
         handleDelete(req, res, objectPath);
         return;
@@ -2077,7 +2077,7 @@
 {
     BMCWEB_ROUTE(app, "/bus/")
         .requires({"Login"})
-        .methods("GET"_method)(
+        .methods(boost::beast::http::verb::get)(
             [](const crow::Request& req, crow::Response& res) {
                 res.jsonValue = {{"buses", {{{"name", "system"}}}},
                                  {"status", "ok"}};
@@ -2086,7 +2086,7 @@
 
     BMCWEB_ROUTE(app, "/bus/system/")
         .requires({"Login"})
-        .methods("GET"_method)(
+        .methods(boost::beast::http::verb::get)(
             [](const crow::Request& req, crow::Response& res) {
                 auto myCallback = [&res](const boost::system::error_code ec,
                                          std::vector<std::string>& names) {
@@ -2115,22 +2115,24 @@
 
     BMCWEB_ROUTE(app, "/list/")
         .requires({"Login"})
-        .methods("GET"_method)(
+        .methods(boost::beast::http::verb::get)(
             [](const crow::Request& req, crow::Response& res) {
                 handleList(res, "/");
             });
 
     BMCWEB_ROUTE(app, "/xyz/<path>")
         .requires({"Login"})
-        .methods("GET"_method)([](const crow::Request& req, crow::Response& res,
-                                  const std::string& path) {
+        .methods(boost::beast::http::verb::get)([](const crow::Request& req,
+                                                   crow::Response& res,
+                                                   const std::string& path) {
             std::string objectPath = "/xyz/" + path;
             handleDBusUrl(req, res, objectPath);
         });
 
     BMCWEB_ROUTE(app, "/xyz/<path>")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("PUT"_method, "POST"_method, "DELETE"_method)(
+        .methods(boost::beast::http::verb::put, boost::beast::http::verb::post,
+                 boost::beast::http::verb::delete_)(
             [](const crow::Request& req, crow::Response& res,
                const std::string& path) {
                 std::string objectPath = "/xyz/" + path;
@@ -2139,15 +2141,17 @@
 
     BMCWEB_ROUTE(app, "/org/<path>")
         .requires({"Login"})
-        .methods("GET"_method)([](const crow::Request& req, crow::Response& res,
-                                  const std::string& path) {
+        .methods(boost::beast::http::verb::get)([](const crow::Request& req,
+                                                   crow::Response& res,
+                                                   const std::string& path) {
             std::string objectPath = "/org/" + path;
             handleDBusUrl(req, res, objectPath);
         });
 
     BMCWEB_ROUTE(app, "/org/<path>")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("PUT"_method, "POST"_method, "DELETE"_method)(
+        .methods(boost::beast::http::verb::put, boost::beast::http::verb::post,
+                 boost::beast::http::verb::delete_)(
             [](const crow::Request& req, crow::Response& res,
                const std::string& path) {
                 std::string objectPath = "/org/" + path;
@@ -2156,8 +2160,9 @@
 
     BMCWEB_ROUTE(app, "/download/dump/<str>/")
         .requires({"ConfigureManager"})
-        .methods("GET"_method)([](const crow::Request& req, crow::Response& res,
-                                  const std::string& dumpId) {
+        .methods(boost::beast::http::verb::get)([](const crow::Request& req,
+                                                   crow::Response& res,
+                                                   const std::string& dumpId) {
             std::regex validFilename("^[\\w\\- ]+(\\.?[\\w\\- ]*)$");
             if (!std::regex_match(dumpId, validFilename))
             {
@@ -2223,19 +2228,23 @@
 
     BMCWEB_ROUTE(app, "/bus/system/<str>/")
         .requires({"Login"})
-        .methods("GET"_method)([](const crow::Request& req, crow::Response& res,
-                                  const std::string& Connection) {
-            introspectObjects(Connection, "/",
-                              std::make_shared<bmcweb::AsyncResp>(res));
-        });
+
+        .methods(boost::beast::http::verb::get)(
+            [](const crow::Request& req, crow::Response& res,
+               const std::string& Connection) {
+                introspectObjects(Connection, "/",
+                                  std::make_shared<bmcweb::AsyncResp>(res));
+            });
 
     BMCWEB_ROUTE(app, "/bus/system/<str>/<path>")
         .requires({"ConfigureComponents", "ConfigureManager"})
-        .methods("GET"_method,
-                 "POST"_method)([](const crow::Request& req,
-                                   crow::Response& res,
-                                   const std::string& processName,
-                                   const std::string& requestedPath) {
+        .methods(
+            boost::beast::http::verb::get,
+            boost::beast::http::verb::post)([](const crow::Request& req,
+                                               crow::Response& res,
+                                               const std::string& processName,
+                                               const std::string&
+                                                   requestedPath) {
             std::vector<std::string> strs;
             boost::split(strs, requestedPath, boost::is_any_of("/"));
             std::string objectPath;
@@ -2532,7 +2541,7 @@
             }
             else
             {
-                if (req.method() != "POST"_method)
+                if (req.method() != boost::beast::http::verb::post)
                 {
                     res.result(boost::beast::http::status::not_found);
                     res.end();
diff --git a/include/redfish_v1.hpp b/include/redfish_v1.hpp
index 3a4b9f5..dfdb900 100644
--- a/include/redfish_v1.hpp
+++ b/include/redfish_v1.hpp
@@ -17,7 +17,7 @@
 void requestRoutes(Crow<Middlewares...>& app)
 {
     BMCWEB_ROUTE(app, "/redfish/")
-        .methods("GET"_method)(
+        .methods(boost::beast::http::verb::get)(
             [](const crow::Request& req, crow::Response& res) {
                 res.jsonValue = {{"v1", "/redfish/v1/"}};
                 res.end();
diff --git a/include/security_headers_middleware.hpp b/include/security_headers_middleware.hpp
index ec72cbb..d3c3335 100644
--- a/include/security_headers_middleware.hpp
+++ b/include/security_headers_middleware.hpp
@@ -13,7 +13,7 @@
     void beforeHandle(crow::Request& req, Response& res, Context& ctx)
     {
 #ifdef BMCWEB_INSECURE_DISABLE_XSS_PREVENTION
-        if ("OPTIONS"_method == req.method())
+        if (boost::beast::http::verb::options == req.method())
         {
             res.end();
         }
diff --git a/redfish-core/include/node.hpp b/redfish-core/include/node.hpp
index 2f4cb6b..74d511f 100644
--- a/redfish-core/include/node.hpp
+++ b/redfish-core/include/node.hpp
@@ -58,39 +58,39 @@
     {
         crow::DynamicRule& get = app.routeDynamic(entityUrl.c_str());
         getRule = &get;
-        get.methods("GET"_method)([this](const crow::Request& req,
-                                         crow::Response& res,
-                                         Params... params) {
-            std::vector<std::string> paramVec = {params...};
-            doGet(res, req, paramVec);
-        });
+        get.methods(boost::beast::http::verb::get)(
+            [this](const crow::Request& req, crow::Response& res,
+                   Params... params) {
+                std::vector<std::string> paramVec = {params...};
+                doGet(res, req, paramVec);
+            });
 
         crow::DynamicRule& patch = app.routeDynamic(entityUrl.c_str());
         patchRule = &patch;
-        patch.methods("PATCH"_method)([this](const crow::Request& req,
-                                             crow::Response& res,
-                                             Params... params) {
-            std::vector<std::string> paramVec = {params...};
-            doPatch(res, req, paramVec);
-        });
+        patch.methods(boost::beast::http::verb::patch)(
+            [this](const crow::Request& req, crow::Response& res,
+                   Params... params) {
+                std::vector<std::string> paramVec = {params...};
+                doPatch(res, req, paramVec);
+            });
 
         crow::DynamicRule& post = app.routeDynamic(entityUrl.c_str());
         postRule = &post;
-        post.methods("POST"_method)([this](const crow::Request& req,
-                                           crow::Response& res,
-                                           Params... params) {
-            std::vector<std::string> paramVec = {params...};
-            doPost(res, req, paramVec);
-        });
+        post.methods(boost::beast::http::verb::post)(
+            [this](const crow::Request& req, crow::Response& res,
+                   Params... params) {
+                std::vector<std::string> paramVec = {params...};
+                doPost(res, req, paramVec);
+            });
 
         crow::DynamicRule& delete_ = app.routeDynamic(entityUrl.c_str());
         deleteRule = &delete_;
-        delete_.methods("DELETE"_method)([this](const crow::Request& req,
-                                                crow::Response& res,
-                                                Params... params) {
-            std::vector<std::string> paramVec = {params...};
-            doDelete(res, req, paramVec);
-        });
+        delete_.methods(boost::beast::http::verb::delete_)(
+            [this](const crow::Request& req, crow::Response& res,
+                   Params... params) {
+                std::vector<std::string> paramVec = {params...};
+                doDelete(res, req, paramVec);
+            });
     }
 
     void initPrivileges()
diff --git a/src/crow_test.cpp b/src/crow_test.cpp
index f53e519..4e0bd40 100644
--- a/src/crow_test.cpp
+++ b/src/crow_test.cpp
@@ -324,22 +324,25 @@
 {
     SimpleApp app;
 
-    BMCWEB_ROUTE(app, "/").methods("POST"_method,
-                                   "GET"_method)([](const Request& req) {
-        if (req.method() == "GET"_method)
-            return "2";
-        else
-            return "1";
-    });
+    BMCWEB_ROUTE(app, "/").methods(boost::beast::http::verb::post,
+                                   boost::beast::http::verb::get)(
+        [](const Request& req) {
+            if (req.method() == boost::beast::http::verb::get)
+                return "2";
+            else
+                return "1";
+        });
 
     BMCWEB_ROUTE(app, "/get_only")
-        .methods("GET"_method)([](const Request& /*req*/) { return "get"; });
+        .methods(boost::beast::http::verb::get)(
+            [](const Request& /*req*/) { return "get"; });
     BMCWEB_ROUTE(app, "/post_only")
-        .methods("POST"_method)([](const Request& /*req*/) { return "post"; });
+        .methods(boost::beast::http::verb::post)(
+            [](const Request& /*req*/) { return "post"; });
 
     // cannot have multiple handlers for the same url
     // BMCWEB_ROUTE(app, "/")
-    //.methods("GET"_method)
+    //.methods(boost::beast::http::verb::get)
     //([]{ return "2"; });
 
     {
@@ -358,7 +361,7 @@
         Response res;
 
         req.url = "/";
-        r.method("POST"_method);
+        r.method(boost::beast::http::verb::post);
         app.handle(req, res);
 
         ASSERT_EQUAL("1", res.body());
@@ -381,7 +384,7 @@
         Response res;
 
         req.url = "/get_only";
-        r.method("POST"_method);
+        r.method(boost::beast::http::verb::post);
         app.handle(req, res);
 
         ASSERT_NOTEQUAL("get", res.body());
@@ -421,10 +424,12 @@
 {
     static char buf[2048];
     SimpleApp app1, app2;
-    BMCWEB_ROUTE(app1, "/").methods("GET"_method,
-                                    "POST"_method)([] { return "A"; });
-    BMCWEB_ROUTE(app2, "/").methods("GET"_method,
-                                    "POST"_method)([] { return "B"; });
+    BMCWEB_ROUTE(app1, "/").methods(boost::beast::http::verb::get,
+                                    boost::beast::http::verb::post)(
+        [] { return "A"; });
+    BMCWEB_ROUTE(app2, "/").methods(boost::beast::http::verb::get,
+                                    boost::beast::http::verb::post)(
+        [] { return "B"; });
 
     Server<SimpleApp> server1(&app1, LOCALHOST_ADDRESS, 45451);
     Server<SimpleApp> server2(&app2, LOCALHOST_ADDRESS, 45452);