correction in the assignment of the end variable and the number variable name

This commit is contained in:
Andrey Kutin 2026-07-19 14:45:47 +03:00
parent 123f180a6d
commit bb85dac1e0
1 changed files with 2 additions and 2 deletions

View File

@ -44,11 +44,11 @@ void HttpSession::processRequest(http::request<http::string_body>&& request) {
} else if (request.method() == http::verb::get && request.target().starts_with("/cards")) { } else if (request.method() == http::verb::get && request.target().starts_with("/cards")) {
std::string number{request.target()}; std::string number{request.target()};
auto start = number.find("?count=") + 7; auto start = number.find("?count=") + 7;
auto end number.find("?", start); auto end = number.find("?", start);
if (end == std::string::npos) { if (end == std::string::npos) {
end = number.length(); end = number.length();
} }
int count = std::stoi(target.substr(start, end - start)); int count = std::stoi(number.substr(start, end - start));
count = std::max(1, std::min(count, 1000)); // валидация count = std::max(1, std::min(count, 1000)); // валидация
json response = db->getRandomRecords(count, 10, 1000); json response = db->getRandomRecords(count, 10, 1000);
res.body() = response.dump(4); res.body() = response.dump(4);