correction in the assignment of the end variable and the number variable name
This commit is contained in:
parent
123f180a6d
commit
bb85dac1e0
|
|
@ -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")) {
|
||||
std::string number{request.target()};
|
||||
auto start = number.find("?count=") + 7;
|
||||
auto end number.find("?", start);
|
||||
auto end = number.find("?", start);
|
||||
if (end == std::string::npos) {
|
||||
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)); // валидация
|
||||
json response = db->getRandomRecords(count, 10, 1000);
|
||||
res.body() = response.dump(4);
|
||||
|
|
|
|||
Loading…
Reference in New Issue