PaoZhu C++ Web Framework比美Java SpringBoot 的注解
PaoZhu C++ Web Framework 内置HTTP/2 ORM 可以完全开发Web生态,提供注解功能。C++ 注解机制更加简单
//@urlpath(admin_islogin,admin/add_article) 一句话可以把一个函数变成注解函数,admin_islogin是拦截函数,访问admin/add_article之前执行认证,如果没有认证,不能执行注解函数。
详细代码,在controller/src目录下创建文件article
//@urlpath(admin_islogin,admin/add_article)
std::string admin_add_article(std::shared_ptr<httppeer> peer)
{
httppeer &client = peer->get_peer();
client<<"Hello World!";
return "";
} 同步模式
//@urlpath(null,queries)
asio::awaitable<std::string> techempowerqueries(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.reserve(get_num);
myworld.lock_conn();
for (unsigned int i = 0; i < get_num; i++)
{
myworld.wheresql.clear();
unsigned int rd_num = rand_range(1, 10000);
myworld.where("id", rd_num);
co_await myworld.async_fetch_append();
}
myworld.unlock_conn();
peer->output = myworld.to_json();
co_return "";
} 他们都是方便利用了注解功能做控制器。
更多入门内容可以访问官方入门文档。
https://hggq.github.io/paozhudocs/documentation.html
Paozhu C++ Web框架 官方github库
https://github.com/hggq/paozhu
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! 谢谢分享,辛苦了 感谢,下载保存了 鼓励转贴优秀软件安全工具和文档! 过来提前占个楼 这个好,看起来很实用 很好很强大我过来先占个楼 待编辑 热心回复! 感谢发布原创作品,程序园因你更精彩 这个好,看起来很实用 新版吗?好像是停更了吧。 这个好,看起来很实用 yyds。多谢分享 这个有用。 感谢分享 感谢分享 热心回复! 用心讨论,共获提升! 感谢分享 感谢分享
页:
[1]
2