本文整理汇总了C++中http::Request::queryParamValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Request::queryParamValue方法的具体用法?C++ Request::queryParamValue怎么用?C++ Request::queryParamValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http::Request
的用法示例。
在下文中一共展示了Request::queryParamValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleFileExportRequest
void handleFileExportRequest(const http::Request& request,
http::Response* pResponse)
{
// see if this is a single or multiple file request
std::string file = request.queryParamValue("file");
if (!file.empty())
{
// resolve alias and ensure that it exists
FilePath filePath = module_context::resolveAliasedPath(file);
if (!filePath.exists())
{
pResponse->setError(http::status::NotFound, "file doesn't exist");
return;
}
// get the name
std::string name = request.queryParamValue("name");
if (name.empty())
{
pResponse->setError(http::status::BadRequest, "name not specified");
return;
}
// download as attachment
setAttachmentResponse(request, name, filePath, pResponse);
}
else
{
handleMultipleFileExportRequest(request, pResponse);
}
}
示例2: handleFileShow
void handleFileShow(const http::Request& request, http::Response* pResponse)
{
// get the file path
FilePath filePath(request.queryParamValue("path"));
if (!filePath.exists())
{
pResponse->setNotFoundError(request.uri());
return;
}
// send it back
pResponse->setCacheWithRevalidationHeaders();
pResponse->setCacheableFile(filePath, request);
}
示例3: handleMultipleFileExportRequest
void handleMultipleFileExportRequest(const http::Request& request,
http::Response* pResponse)
{
// name parameter
std::string name = request.queryParamValue("name");
if (name.empty())
{
pResponse->setError(http::status::BadRequest, "name not specified");
return;
}
// parent parameter
std::string parent = request.queryParamValue("parent");
if (parent.empty())
{
pResponse->setError(http::status::BadRequest, "parent not specified");
return;
}
FilePath parentPath = module_context::resolveAliasedPath(parent);
if (!parentPath.exists())
{
pResponse->setError(http::status::BadRequest, "parent doesn't exist");
return;
}
// files parameters (paths relative to parent)
std::vector<std::string> files;
for (int i=0; ;i++)
{
// get next file (terminate when we stop finding files)
std::string fileParam = "file" + boost::lexical_cast<std::string>(i);
std::string file = request.queryParamValue(fileParam);
if (file.empty())
break;
// verify that the file exists
FilePath filePath = parentPath.complete(file);
if (!filePath.exists())
{
pResponse->setError(http::status::BadRequest,
"file " + file + " doesn't exist");
return;
}
// add it
files.push_back(file);
}
// create the zip file
FilePath tempZipFilePath = module_context::tempFile("export", "zip");
Error error = r::exec::RFunction(".rs.createZipFile",
tempZipFilePath.absolutePath(),
parentPath.absolutePath(),
files).call();
if (error)
{
LOG_ERROR(error);
pResponse->setError(error);
return;
}
// return attachment
setAttachmentResponse(request, name, tempZipFilePath, pResponse);
}