summaryrefslogtreecommitdiff
path: root/include/webassets.hpp
diff options
context:
space:
mode:
authorzhanghch05 <zhanghch05@inspur.com>2021-04-01 06:18:24 +0300
committerzhanghch05 <zhanghch05@inspur.com>2021-04-08 04:01:21 +0300
commit8d1b46d7f8d39db2ba048f9e9007106ca3a28c9b (patch)
tree821fcb9b383fdf3db22db77e154cd7f57606d402 /include/webassets.hpp
parentdab0604af234bdd5010407031a01343d6c242edf (diff)
downloadbmcweb-8d1b46d7f8d39db2ba048f9e9007106ca3a28c9b.tar.xz
Using AsyncResp everywhere
Get the core using AsyncResp everywhere, and not have each individual handler creating its own object.We can call app.handle() without fear of the response getting ended after the first tree is done populating. Don't use res.end() anymore. Tested: 1. Validator passed. Signed-off-by: zhanghaicheng <zhanghch05@inspur.com> Change-Id: I867367ce4a0caf8c4b3f4e07e06c11feed0782e8
Diffstat (limited to 'include/webassets.hpp')
-rw-r--r--include/webassets.hpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/include/webassets.hpp b/include/webassets.hpp
index 97a0194b61..070442e79b 100644
--- a/include/webassets.hpp
+++ b/include/webassets.hpp
@@ -143,16 +143,18 @@ inline void requestRoutes(App& app)
}
app.routeDynamic(webpath)(
- [absolutePath, contentType,
- contentEncoding](const crow::Request&, crow::Response& res) {
+ [absolutePath, contentType, contentEncoding](
+ const crow::Request&,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
if (contentType != nullptr)
{
- res.addHeader("Content-Type", contentType);
+ asyncResp->res.addHeader("Content-Type", contentType);
}
if (contentEncoding != nullptr)
{
- res.addHeader("Content-Encoding", contentEncoding);
+ asyncResp->res.addHeader("Content-Encoding",
+ contentEncoding);
}
// res.set_header("Cache-Control", "public, max-age=86400");
@@ -160,15 +162,14 @@ inline void requestRoutes(App& app)
if (!inf)
{
BMCWEB_LOG_DEBUG << "failed to read file";
- res.result(
+ asyncResp->res.result(
boost::beast::http::status::internal_server_error);
- res.end();
return;
}
- res.body() = {std::istreambuf_iterator<char>(inf),
- std::istreambuf_iterator<char>()};
- res.end();
+ asyncResp->res.body() = {
+ std::istreambuf_iterator<char>(inf),
+ std::istreambuf_iterator<char>()};
});
}
}