1
0

Begin removing several dependencies on Config object

Este cometimento está contido em:
2019-09-29 17:12:36 +02:00
ascendente 327c0793d1
cometimento 364d82a99f
9 ficheiros modificados com 127 adições e 79 eliminações

Ver ficheiro

@ -24,5 +24,16 @@ SOFTWARE.
std::unique_ptr<GatewayInterface> createGateway(const Config &c)
{
return std::make_unique<HttpGateway>(c);
std::string listenaddr = c.configVarResolver.getConfig("http.listenaddr");
if(listenaddr.empty())
{
throw new std::runtime_error("No http.listenaddr in config file");
}
std::string listenport = c.configVarResolver.getConfig("http.listenport");
if(listenport.empty())
{
throw new std::runtime_error("No http.listenport in config file");
}
return std::make_unique<HttpGateway>(listenaddr, std::stoi(listenport), c.max_payload_length);
}

Ver ficheiro

@ -20,21 +20,11 @@ SOFTWARE.
*/
#include "httpgateway.h"
#include "../logger.h"
HttpGateway::HttpGateway(const Config &config)
HttpGateway::HttpGateway(std::string listenaddr, int port, uint64_t maxPayloadLength)
{
this->listenaddr = config.getConfig("http.listenaddr");
if(this->listenaddr.empty())
{
throw new std::runtime_error("No http.listenaddr in config file");
}
std::string listenport = config.getConfig("http.listenport");
if(listenport.empty())
{
throw new std::runtime_error("No http.listenport in config file");
}
this->listenport = std::stoi(listenport);
this->maxPayloadLength = config.max_payload_length;
this->listenaddr = listenaddr;
this->listenport = port;
this->maxPayloadLength = maxPayloadLength;
}
bool HttpGateway::keepReading()

Ver ficheiro

@ -19,7 +19,7 @@ class HttpGateway : public GatewayInterface
uint64_t maxPayloadLength;
public:
HttpGateway(const Config &config);
HttpGateway(std::string listenaddr, int port, uint64_t maxPayloadLength);
bool keepReading() override;
void work(RequestWorker &worker) override;
};