ipkn / crow

Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)
BSD 3-Clause "New" or "Revised" License
7.47k stars 888 forks source link

POST Call #295

Open sanjoy-gwtp opened 6 years ago

sanjoy-gwtp commented 6 years ago

error: C3688: invalid literal suffix '_method'; literal operator or literal operator template 'operator ""_method' not found

Shravan40 commented 6 years ago

Could you please provide us whole POST method, which you are trying to compile ?

sanjoy-gwtp commented 6 years ago

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()}; });

Shravan40 commented 6 years ago

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.

netromdk commented 6 years ago

@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.

sanjoy-gwtp commented 6 years ago

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()}; });