#ifndef VRPMDV_STATICCONTROLLER_HPP #define VRPMDV_STATICCONTROLLER_HPP #include "oatpp/web/server/api/ApiController.hpp" #include "oatpp/parser/json/mapping/ObjectMapper.hpp" #include "oatpp/core/macro/codegen.hpp" #include "oatpp/core/macro/component.hpp" #include #include OATPP_CODEGEN_BEGIN(ApiController) //<- Begin Codegen class StaticController : public oatpp::web::server::api::ApiController { private: oatpp::String m_resDir = "./"; public: StaticController(const std::shared_ptr& objectMapper) : oatpp::web::server::api::ApiController(objectMapper) {} public: static std::shared_ptr createShared( OATPP_COMPONENT(std::shared_ptr, objectMapper) // Inject objectMapper component here as default parameter ){ return std::make_shared(objectMapper); } ENDPOINT("GET", "/", root) { // const char* html = // "" // " " // " " // " " // " " // "

Hello CRUD example project!

" // " Checkout Swagger-UI page" // " " // ""; oatpp::String html;// = loadFromFile("index.html"); const oatpp::String htmlsend = html.loadFromFile("./webui/index.html"); auto response = createResponse(Status::CODE_200, htmlsend); response->putHeader(Header::CONTENT_TYPE, "text/html"); return response; } // oatpp::String loadFromFile(const char* fileName) { // auto fullFilename = m_resDir + fileName; // std::ifstream file (fullFilename->c_str(), std::ios::in|std::ios::binary|std::ios::ate); // if (file.is_open()) { // auto result = oatpp::String((v_int32) file.tellg()); // file.seekg(0, std::ios::beg); // file.read((char*)result->data(), result->size()); // file.close(); // return result; // } }; #include OATPP_CODEGEN_END(ApiController) //<- End Codegen #endif //VRPMDV_STATICCONTROLLER_HPP