void PetApi::upload_file_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { try { this->upload_file(request, response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void UserApi::logout_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { try { this->logout_user(response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void UserApi::get_user_by_name_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { // Getting the path params auto username = request.param(":username").as<std::string>(); try { this->get_user_by_name(username, response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void PetApi::get_pet_by_id_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { // Getting the path params auto petId = request.param(":petId").as<int64_t>(); try { this->get_pet_by_id(petId, response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void PetApi::find_pets_by_status_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { // Getting the query params auto status = request.query().get("status"); try { this->find_pets_by_status(status, response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void UserApi::login_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { // Getting the query params auto username = request.query().get("username"); auto password = request.query().get("password"); try { this->login_user(username, password, response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void PetApi::delete_pet_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { // Getting the path params auto petId = request.param(":petId").as<int64_t>(); // Getting the header params auto apiKey = request.headers().tryGetRaw("api_key"); try { this->delete_pet(petId, apiKey, response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void PetApi::add_pet_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { // Getting the body param Pet pet; try { nlohmann::json request_body = nlohmann::json::parse(request.body()); pet.fromJson(request_body); this->add_pet(pet, response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void UserApi::create_users_with_list_input_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { // Getting the body param std::vector user; try { nlohmann::json request_body = nlohmann::json::parse(request.body()); user.fromJson(request_body); this->create_users_with_list_input(user, response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void UserApi::update_user_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { // Getting the path params auto username = request.param(":username").as<std::string>(); // Getting the body param User user; try { nlohmann::json request_body = nlohmann::json::parse(request.body()); user.fromJson(request_body); this->update_user(username, user, response); } catch (std::runtime_error & e) { //send a 400 error response.send(Pistache::Http::Code::Bad_Request, e.what()); return; } }
void PetApiImpl::update_pet_with_form(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response){ response.send(Pistache::Http::Code::Ok, "Do some magic\n"); }
void PetApiImpl::upload_file(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response){ response.send(Pistache::Http::Code::Ok, "Do some magic\n"); }
void PetApiImpl::update_pet(const std::shared_ptr<Pet> &pet, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); }
void PetApiImpl::get_pet_by_id(const int64_t &petId, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); }
void PetApiImpl::find_pets_by_tags(const Pistache::Optional<std::string> &tags, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); }
void PetApiImpl::delete_pet(const int64_t &petId, const Pistache::Optional<Pistache::Http::Header::Raw> &apiKey, Pistache::Http::ResponseWriter &response) { response.send(Pistache::Http::Code::Ok, "Do some magic\n"); }
void UserApi::user_api_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response) { response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist"); }