目前Paozhu C++ Web Framework 已经完成一个完整的web生态开发框架,内置HTTP/1 HTTP/2 ORM
支持基于ASIO协程ORM,目前全球第二款开源基于ASIO协程 MySQL Client
http::obj_val hval;
hval["aaa"]=3344;
hval["bbb"]="1234567890";
std::cout<<"ll:"<<hval["aaa"].to_int()<<std::endl;
std::cout<<"vv:|"<<static_cast<int>(hval["bbb"].get_type())<<"|"<<std::endl;
if(hval["bbb"].is_string())
{
std::cout<<"str:"<<hval["bbb"].to_string()<<std::endl;
std::cout<<"str:"<<hval["bbb"].str_view()<<std::endl;
std::cout<<"str:"<<hval["bbb"].str_view(2,5)<<std::endl;
}
http::obj_val nval;
nval.from_json("{\"bba\":[[[111,222],[333,444],[555,666]],[[777,888],[999,1111],[2222,3333]],[[4444,5555],[6666,7777],[8888,9999]]]}");
std::cout<<"json out:"<<nval.to_json()<<std::endl;
std::string bbb=nval.to_json();
http::obj_val pval;
pval.from_json(bbb);
//@urlpath(null,updates)
asio::awaitable<std::string> techempowerupdates(std::shared_ptr<httppeer> peer)
{
peer->type("application/json; charset=UTF-8");
peer->set_header("Date", get_gmttime());
unsigned int get_num = peer->get["queries"].to_int();
if (get_num == 0)
{
get_num = 1;
}
else if (get_num > 500)
{
get_num = 500;
}
auto myworld = orm::World();
myworld.record.clear();
myworld.record.reserve(get_num);
for (unsigned int i = 0; i < get_num; i++)
{
myworld.wheresql.clear();
myworld.where("id", rand_range(1, 10000));
co_await myworld.async_fetch_append();
if (myworld.effect() > 0)
{
unsigned int j = myworld.record.size() - 1;
myworld.data.randomnumber= rand_range(1, 10000);
myworld.record[j].randomnumber = myworld.data.randomnumber;
co_await myworld.async_update("randomnumber");
}
}
peer->output = myworld.to_json();
co_return "";
}
https://github.com/hggq/paozhu