本文整理汇总了C++中http_request::get_path_piece方法的典型用法代码示例。如果您正苦于以下问题:C++ http_request::get_path_piece方法的具体用法?C++ http_request::get_path_piece怎么用?C++ http_request::get_path_piece使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http_request
的用法示例。
在下文中一共展示了http_request::get_path_piece方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_GET
void resource_shouts::render_GET(http_request const & request, http_response * * const response)
{
auto json = Json::Value{Json::arrayValue};
auto builder = http_response_builder{""};
auto id = request.get_path_piece(1);
if(id.size())
{
if(user_exists(m_redis, id))
{
auto shouts = shouts_getall_for_user(m_redis, id);
for_each(shouts.cbegin(), shouts.cend(), [&](auto const & shout){
json.append(shout.json());
});
builder = http_response_builder{json.toStyledString(), 200, "application/json"};
}
else
{
builder = http_response_builder{kUserInvalid, 400};
}
}
else
{
auto shouts = shouts_getall(m_redis);
for_each(shouts.cbegin(), shouts.cend(), [&](auto const & shout){
json.append(shout.json());
});
builder = http_response_builder{json.toStyledString(), 200, "application/json"};
}
*response = new http_response{builder};
}