Begin removing several dependencies on Config object

此提交包含在:
2019-09-29 17:12:36 +02:00
父節點 3b312c7d9e
當前提交 083f7ff842
共有 9 個檔案被更改,包括 135 行新增85 行删除

查看文件

@ -24,6 +24,18 @@ 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()

查看文件

@ -18,7 +18,7 @@ private:
int listenport;
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;
};