Begin removing several dependencies on Config object
Este cometimento está contido em:
@ -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);
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
};
|
||||
|
Criar uma nova questão referindo esta
Bloquear um utilizador