aozhiwei afc8ceddac 1
2023-11-24 21:06:44 +08:00

47 lines
1.0 KiB
C++

#pragma once
#include <a8/singleton.h>
#include "f8/httpclientpool.h"
namespace a8
{
class Awaiter;
}
struct HttpProxyRequest;
class HttpProxy : public a8::Singleton<HttpProxy>
{
private:
HttpProxy() {};
friend class a8::Singleton<HttpProxy>;
public:
void Init();
void UnInit();
std::string HttpGet(
f8::HttpProxyCb cb,
const char* url,
a8::XObject url_params
);
std::shared_ptr<HttpProxyRequest> GetRequest(const std::string& req_id);
void DestoryRequest(std::shared_ptr<HttpProxyRequest> request);
std::shared_ptr<a8::Awaiter> CoHttpGet(const char* url,
a8::XObject url_params,
bool* ret,
std::shared_ptr<a8::XObject>* rsp);
private:
std::string CreateRequestId();
private:
std::map<std::string, std::shared_ptr<HttpProxyRequest>> request_hash_;
std::string request_prefix_;
};