①先说不需要token的请求方式,代码如下所示:
std::wstringstream suffix;
std::wstring uri = conversions::to_string_t(gateway->uri);
suffix << uri << L"?page=" << pageNum << L"&page_size=" << pageSize << L"&count=false";
utility::string_t addr = U("http://");
addr.append(conversions::to_string_t(gateway->host));
addr.append(U(":"));
addr.append(conversions::to_string_t(gateway->port));
web::http::client::http_client client(addr);
uri_builder builder(suffix.str());
http_response response = client.request(methods::GET, builder.to_string()).get();
concurrency::streams::stringstreambuf buffer;
response.body().read_to_end(buffer).get();
std::string& json = buffer.collection();
//解析json
其中gateway是一个网关的结构体,里面包含了网关的ip地址,端口号等信息,这里采用的是分页查询方式,采用get方式请求数据,返回数据为json格式。
②带token的请求方式,代码如下所示:</