Open sanjoy-gwtp opened 6 years ago
Could you please provide us whole POST method, which you are trying to compile ?
CROW_ROUTE(app, "/add_json") .methods("POST"_method) ([](const crow::request& req){ auto x = crow::json::load(req.body); if (!x) return crow::response(400); int sum = x["a"].i()+x["b"].i(); std::ostringstream os; os << sum; return crow::response{os.str()}; });
It's the same example given in project description. And it's working fine at my machine. Please post the complete error log, with the command you are using to compile it.
@sanjoy-gwtp, it looks like you're using MSVC. Which version are using? Be sure not to have CROW_MSVC_WORKAROUND
defined and to use MSVC 2013 or 2015+. I've successfully used 2015 myself.
I find my solution.
CROW_ROUTE(app, "/add_json") .methods("POST"_method) it will be methods(crow::HTTPMethod::Post) ([](const crow::request& req){ auto x = crow::json::load(req.body); if (!x) return crow::response(400); int sum = x["a"].i()+x["b"].i(); std::ostringstream os; os << sum; return crow::response{os.str()}; });
error: C3688: invalid literal suffix '_method'; literal operator or literal operator template 'operator ""_method' not found