129 lines
4.1 KiB
C++
129 lines
4.1 KiB
C++
/**
|
|
* Jungfraujoch writer
|
|
* Jungfraujoch Writer Web API
|
|
*
|
|
* The version of the OpenAPI document: 1.0.0.rc_11
|
|
*
|
|
*
|
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
* https://openapi-generator.tech
|
|
* Do not edit the class manually.
|
|
*/
|
|
|
|
#include "DefaultApi.h"
|
|
#include "Helpers.h"
|
|
|
|
namespace org::openapitools::server::api
|
|
{
|
|
|
|
using namespace org::openapitools::server::helpers;
|
|
using namespace org::openapitools::server::model;
|
|
|
|
const std::string DefaultApi::base = "";
|
|
|
|
DefaultApi::DefaultApi(const std::shared_ptr<Pistache::Rest::Router>& rtr)
|
|
: router(rtr)
|
|
{
|
|
}
|
|
|
|
void DefaultApi::init() {
|
|
setupRoutes();
|
|
}
|
|
|
|
void DefaultApi::setupRoutes() {
|
|
using namespace Pistache::Rest;
|
|
|
|
Routes::Post(*router, base + "/cancel", Routes::bind(&DefaultApi::cancel_post_handler, this));
|
|
Routes::Get(*router, base + "/status", Routes::bind(&DefaultApi::status_get_handler, this));
|
|
Routes::Get(*router, base + "/version", Routes::bind(&DefaultApi::version_get_handler, this));
|
|
|
|
// Default handler, called when a route is not found
|
|
router->addCustomHandler(Routes::bind(&DefaultApi::default_api_default_handler, this));
|
|
}
|
|
|
|
std::pair<Pistache::Http::Code, std::string> DefaultApi::handleParsingException(const std::exception& ex) const noexcept
|
|
{
|
|
try {
|
|
throw;
|
|
} catch (nlohmann::detail::exception &e) {
|
|
return std::make_pair(Pistache::Http::Code::Bad_Request, e.what());
|
|
} catch (org::openapitools::server::helpers::ValidationException &e) {
|
|
return std::make_pair(Pistache::Http::Code::Bad_Request, e.what());
|
|
} catch (std::exception &e) {
|
|
return std::make_pair(Pistache::Http::Code::Internal_Server_Error, e.what());
|
|
}
|
|
}
|
|
|
|
std::pair<Pistache::Http::Code, std::string> DefaultApi::handleOperationException(const std::exception& ex) const noexcept
|
|
{
|
|
return std::make_pair(Pistache::Http::Code::Internal_Server_Error, ex.what());
|
|
}
|
|
|
|
void DefaultApi::cancel_post_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
|
|
try {
|
|
|
|
|
|
try {
|
|
this->cancel_post(response);
|
|
} catch (Pistache::Http::HttpError &e) {
|
|
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
|
|
return;
|
|
} catch (std::exception &e) {
|
|
const std::pair<Pistache::Http::Code, std::string> errorInfo = this->handleOperationException(e);
|
|
response.send(errorInfo.first, errorInfo.second);
|
|
return;
|
|
}
|
|
|
|
} catch (std::exception &e) {
|
|
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
|
|
}
|
|
|
|
}
|
|
void DefaultApi::status_get_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
|
|
try {
|
|
|
|
|
|
try {
|
|
this->status_get(response);
|
|
} catch (Pistache::Http::HttpError &e) {
|
|
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
|
|
return;
|
|
} catch (std::exception &e) {
|
|
const std::pair<Pistache::Http::Code, std::string> errorInfo = this->handleOperationException(e);
|
|
response.send(errorInfo.first, errorInfo.second);
|
|
return;
|
|
}
|
|
|
|
} catch (std::exception &e) {
|
|
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
|
|
}
|
|
|
|
}
|
|
void DefaultApi::version_get_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
|
|
try {
|
|
|
|
|
|
try {
|
|
this->version_get(response);
|
|
} catch (Pistache::Http::HttpError &e) {
|
|
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
|
|
return;
|
|
} catch (std::exception &e) {
|
|
const std::pair<Pistache::Http::Code, std::string> errorInfo = this->handleOperationException(e);
|
|
response.send(errorInfo.first, errorInfo.second);
|
|
return;
|
|
}
|
|
|
|
} catch (std::exception &e) {
|
|
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
|
|
}
|
|
|
|
}
|
|
|
|
void DefaultApi::default_api_default_handler(const Pistache::Rest::Request &, Pistache::Http::ResponseWriter response) {
|
|
response.send(Pistache::Http::Code::Not_Found, "The requested method does not exist");
|
|
}
|
|
|
|
} // namespace org::openapitools::server::api
|
|
|