Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions frameworks/drogon/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ struct DataItem {
bool active;
std::vector<std::string> tags;
Rating rating;
double total;
};
static std::vector<DataItem> dataset;

Expand Down Expand Up @@ -88,7 +87,6 @@ static void loadDataset()
for (const auto &t : d["tags"]) item.tags.push_back(t.asString());
item.rating.score = d["rating"]["score"].asDouble();
item.rating.count = d["rating"]["count"].asInt64();
item.total = std::round(item.price * item.quantity * 100.0) / 100.0;
dataset.push_back(std::move(item));
}
}
Expand Down Expand Up @@ -204,7 +202,7 @@ class BenchmarkCtrl : public drogon::HttpController<BenchmarkCtrl>
rating["score"] = d.rating.score;
rating["count"] = static_cast<Json::Int64>(d.rating.count);
item["rating"] = std::move(rating);
item["total"] = d.total;
item["total"] = std::round(d.price * d.quantity * 100.0) / 100.0;
items.append(std::move(item));
}
respJson["items"] = std::move(items);
Expand All @@ -213,7 +211,7 @@ class BenchmarkCtrl : public drogon::HttpController<BenchmarkCtrl>
wb["indentation"] = "";
auto resp = HttpResponse::newHttpResponse();
resp->setBody(Json::writeString(wb, respJson));
resp->setContentTypeCode(CT_APPLICATION_JSON);
resp->setContentTypeString("application/json");
callback(resp);
} else {
auto resp = HttpResponse::newHttpResponse();
Expand All @@ -229,7 +227,7 @@ class BenchmarkCtrl : public drogon::HttpController<BenchmarkCtrl>
if (!json_large_response.empty()) {
auto resp = HttpResponse::newHttpResponse();
resp->setBody(json_large_response);
resp->setContentTypeCode(CT_APPLICATION_JSON);
resp->setContentTypeString("application/json");
callback(resp);
} else {
auto resp = HttpResponse::newHttpResponse();
Expand Down Expand Up @@ -280,7 +278,7 @@ class BenchmarkCtrl : public drogon::HttpController<BenchmarkCtrl>
if (!db_available || !getDb() || !tl_stmt) {
auto resp = HttpResponse::newHttpResponse();
resp->setBody("{\"items\":[],\"count\":0}");
resp->setContentTypeCode(CT_APPLICATION_JSON);
resp->setContentTypeString("application/json");
callback(resp);
return;
}
Expand Down Expand Up @@ -321,7 +319,7 @@ class BenchmarkCtrl : public drogon::HttpController<BenchmarkCtrl>
wb["indentation"] = "";
auto resp = HttpResponse::newHttpResponse();
resp->setBody(Json::writeString(wb, respJson));
resp->setContentTypeCode(CT_APPLICATION_JSON);
resp->setContentTypeString("application/json");
callback(resp);
}

Expand All @@ -333,7 +331,7 @@ class BenchmarkCtrl : public drogon::HttpController<BenchmarkCtrl>
if (it != static_files.end()) {
auto resp = HttpResponse::newHttpResponse();
resp->setBody(it->second.data);
resp->addHeader("Content-Type", it->second.content_type);
resp->setContentTypeString(it->second.content_type);
callback(resp);
} else {
auto resp = HttpResponse::newHttpResponse();
Expand Down
1 change: 0 additions & 1 deletion frameworks/drogon/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"limited-conn",
"json",
"upload",
"compression",
"mixed",
"baseline-h2",
"static-h2"
Expand Down
Loading