2017-04-04 19:58:40 +00:00
|
|
|
#include "submit_form_response.hpp"
|
2017-04-06 20:27:38 +00:00
|
|
|
#include "incredis/incredis.hpp"
|
|
|
|
#include "cgi_post.hpp"
|
2017-04-04 19:58:40 +00:00
|
|
|
|
|
|
|
namespace tawashi {
|
2017-04-06 20:27:38 +00:00
|
|
|
namespace {
|
|
|
|
const char g_post_key[] = "tawashi";
|
|
|
|
|
|
|
|
bool submit_to_redis (const std::string& parText) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} //unnamed namespace
|
|
|
|
|
|
|
|
SubmitFormResponse::SubmitFormResponse (redis::IncRedis& parRedis) :
|
|
|
|
Response("text/html"),
|
|
|
|
m_redis(parRedis)
|
2017-04-04 19:58:40 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SubmitFormResponse::on_send (std::ostream& parStream) {
|
2017-04-06 20:27:38 +00:00
|
|
|
auto post = cgi::read_post(cgi_env());
|
|
|
|
auto post_data_it = post.find(g_post_key);
|
|
|
|
if (post.end() != post_data_it) {
|
|
|
|
parStream << "can't find POST data\n";
|
|
|
|
}
|
|
|
|
else if (submit_to_redis(post_data_it->second)) {
|
|
|
|
parStream << "post submitted correctly\n";
|
|
|
|
}
|
2017-04-04 19:58:40 +00:00
|
|
|
}
|
|
|
|
} //namespace tawashi
|