Added url/router-prefix to ApiController

This commit is contained in:
Benedikt-Alexander Mokroß 2019-10-10 16:43:58 +02:00
parent 7cf4d9e769
commit 0dc3743a05
2 changed files with 5 additions and 3 deletions

View File

@ -288,7 +288,7 @@ std::shared_ptr<Endpoint::Info> Z__EDNPOINT_INFO_GET_INSTANCE_##NAME() { \
EndpointInfoBuilder Z__CREATE_ENDPOINT_INFO_##NAME = [this](){ \
auto info = Z__EDNPOINT_INFO_GET_INSTANCE_##NAME(); \
info->name = #NAME; \
info->path = PATH; \
info->path = ((m_routerPrefix != nullptr) ? m_routerPrefix + PATH : PATH); \
info->method = METHOD; \
return info; \
}; \
@ -317,7 +317,7 @@ std::shared_ptr<oatpp::web::protocol::http::outgoing::Response> NAME()
EndpointInfoBuilder Z__CREATE_ENDPOINT_INFO_##NAME = [this](){ \
auto info = Z__EDNPOINT_INFO_GET_INSTANCE_##NAME(); \
info->name = #NAME; \
info->path = PATH; \
info->path = ((m_routerPrefix != nullptr) ? m_routerPrefix + PATH : PATH); \
info->method = METHOD; \
OATPP_MACRO_FOREACH(OATPP_MACRO_API_CONTROLLER_FOR_EACH_PARAM_INFO, __VA_ARGS__) \
return info; \

View File

@ -279,11 +279,13 @@ protected:
std::shared_ptr<oatpp::data::mapping::ObjectMapper> m_defaultObjectMapper;
std::unordered_map<std::string, std::shared_ptr<Endpoint::Info>> m_endpointInfo;
std::unordered_map<std::string, std::shared_ptr<RequestHandler>> m_endpointHandlers;
const oatpp::String m_routerPrefix;
public:
ApiController(const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& defaultObjectMapper)
ApiController(const std::shared_ptr<oatpp::data::mapping::ObjectMapper>& defaultObjectMapper, const oatpp::String &routerPrefix = nullptr)
: m_endpoints(Endpoints::createShared())
, m_errorHandler(nullptr)
, m_defaultObjectMapper(defaultObjectMapper)
, m_routerPrefix(routerPrefix)
{}
public: