I have a source code
Now I want to take some input from the user and then post it in req.reply. For that I tried this
But somehow the compiler throws this error.
1>Listener.cpp(36): error C3493: 'strName' cannot be implicitly captured because no default capture mode has been specified
1>Listener.cpp(36): error C2664: 'pplx::task<void> web::http::http_request::reply(web::http::status_code,const utility::string_t &,utility::string_t) const' : cannot convert parameter 2 from 'std::string' to 'const utility::string_t &'
1> Reason: cannot convert from 'std::string' to 'const utility::string_t'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Code:
listener.support(methods::GET, [](http_request req)
{
std::cout << "Serving GET" << std::endl;
//req.reply(status_codes::OK, U("input string!"), U("text/html"));
req.reply(status_codes::OK, U("<html><body><h1>It works!</h1>(Casablanca, that is a GET Request.)</body></html>"), U("text/html"));
});
Code:
std::string strName;
std::cin >> strName;
req.reply(status_codes::OK, strName, U("text/html"));
Quote:
1>Listener.cpp(36): error C3493: 'strName' cannot be implicitly captured because no default capture mode has been specified
1>Listener.cpp(36): error C2664: 'pplx::task<void> web::http::http_request::reply(web::http::status_code,const utility::string_t &,utility::string_t) const' : cannot convert parameter 2 from 'std::string' to 'const utility::string_t &'
1> Reason: cannot convert from 'std::string' to 'const utility::string_t'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========