我正在尝试使用 C++ REST SDK 编写自己的 REST 服务器实现。使用的类是 http_listener。几乎所有它都能正确编译,但是当我尝试使用类 web::http::URI 构建一个 URI 时,它会给我错误,如果将 URI 传递给 http_listener 类它也会出错。在我们下面给出错误的代码。
void CPPRESTSERVER::Start()
{
//building the URI//
utility::string_t address = "http://";
address.append(m_IP);
address.append(":");
address.append(std::to_string(m_port));
address.append("/");
m_Uri(U(address)); //m_Uri class member of type web::http::uri
//m_CustUri(m_Uri);
//m_CustUri.append_path(m_pathIP);
//m_CustUri.set_port(m_port);
//*******************
m_rstServer(U(m_Uri.to_string())); //m_rstserver class member of type http_listener
m_rstServer.support(web::http::methods::GET, std::bind(&CPPRESTSERVER::handle_GET, this, std::placeholders::_1));
}
我已经尝试了以下
1) m_Uri(U(address)); also as m_Uri(address); but still giving errors.
2) m_rstServer(U(m_Uri.to_string())); also as m_rstServer(m_Uri.to_string()); also as m_rstServer(m_Uri); also as m_rstServer(U(m_Uri));
但是即使他们有各自的函数的 cusntructors 接受所需类型的参数,他们仍然会给出错误
CPPRESTSERVER.cpp:57:21: error: no match for call to ‘(web::uri) (utility::string_t&)’
m_Uri(U(address));
^
CPPRESTSERVER.cpp:62:25: error: no match for call to ‘(web::http::experimental::listener::http_listener) (web::uri&)’
m_rstServer(U(m_Uri.to_string()));
有什么建议么??????由于这两个错误,我卡住了。我也在使用 C++11 标准在 ubuntu 中编译。