iam developing a rest service in c++ for a wordpress client in a project for a further education. The service is written in c++ using casablanca as framework for and service and client communicate over JSON.
Now I have to send PDF Files to each other. Can sb. tell me a method or an example to do this without sending direct links for a download?
http://casablanca.codeplex.com/
Here is my function to start the server and add the support methods.
void Commanagement::Init(utility::string_t url, utility::string_t port)
{
this->url = &url;
this->port = &port;
listener = new http_listener(U("http://localhost:4711"));
listener->support(methods::GET, std::bind(&Commanagement::handle_GET, this, std::placeholders::_1));
listener->support(methods::POST, std::bind(&Commanagement::handle_POST, this, std::placeholders::_1));
listener->open().wait();
}
And an example of sending a JSON response to my client.
void Commanagement::handle_POST(http_request message)
{
ucout << message.extract_json().wait();
auto paths = http::uri::split_path(http::uri::decode(message.relative_uri().path()));
json::value postData;
postData[L"id"] = json::value::number(13);
postData[L"FirstVal"] = json::value::string(L"Baseball");
postData[L"SomeVal"] = json::value::string(L"test");
message.reply(web::http::status_codes::OK, postData.serialize()).wait();
}