httpgateway: take listen/port data from config file
这个提交包含在:
		| @@ -22,7 +22,17 @@ SOFTWARE. | |||||||
| #include "../logger.h" | #include "../logger.h" | ||||||
| HttpGateway::HttpGateway(const Config &config) | HttpGateway::HttpGateway(const Config &config) | ||||||
| { | { | ||||||
|  | 	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); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool HttpGateway::keepReading() | bool HttpGateway::keepReading() | ||||||
| @@ -91,5 +101,5 @@ void HttpGateway::work(RequestWorker &worker) | |||||||
| 	}; | 	}; | ||||||
| 	server.Get("/(.*)", handler); | 	server.Get("/(.*)", handler); | ||||||
| 	server.Post("/(.*)", handler); | 	server.Post("/(.*)", handler); | ||||||
| 	server.listen("127.0.0.1", 1234); | 	server.listen(this->listenaddr.c_str(), this->listenport); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -13,6 +13,9 @@ private: | |||||||
| 	httplib::Response convertResponse(Response response); | 	httplib::Response convertResponse(Response response); | ||||||
| 	Request convertRequest(httplib::Request request); | 	Request convertRequest(httplib::Request request); | ||||||
|   //  void worker(const httplib::Request& req, httplib::Response& res); |   //  void worker(const httplib::Request& req, httplib::Response& res); | ||||||
|  |  | ||||||
|  | 	std::string listenaddr; | ||||||
|  | 	int listenport; | ||||||
| public: | public: | ||||||
| 	HttpGateway(const Config &config); | 	HttpGateway(const Config &config); | ||||||
| 	bool keepReading() override; | 	bool keepReading() override; | ||||||
|   | |||||||
		在新工单中引用
	
	屏蔽一个用户