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 "";
}
这样可以在浏览器http://localhost/admin/add_article 这样访问了,非常简单地输出了Hello World! 到浏览器,是不是很惊讶,C++ 怎么做到的,这就是PaoZhu C++ Web Framework。
PaoZhu ORM提供协程和同步模式支持。
协程模式
//@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 "";
}
同步模式
//@urlpath(admin_islogin,admin/addtopic)
std::string admin_addtopic(std::shared_ptr<httppeer> peer)
{
httppeer &client = peer->get_peer();
try
{
auto topicm = orm::cms::Topic();
topicm.where("userid", client.session["userid"].to_int()).asc("parentid").fetch(); client.val["list"].set_array();
obj_val temp; for (unsigned int i = 0; i < topicm.record.size(); i++)
{
temp["id"] = topicm.record[i].topicid;
temp["parentid"] = topicm.record[i].parentid;
temp["value"] = topicm.record[i].title;
client.val["list"].push(temp);
}
}
catch (std::exception &e)
{
client.val["code"] = 1;
} peer->view("admin/addtopic");
return "";
}
他们都是方便利用了注解功能做控制器。
更多入门内容可以访问官方入门文档。
https://hggq.github.io/paozhudocs/documentation.html
官方github库
https://github.com/hggq/paozhu
PaoZhu C++ Web Framework比美Java SpringBoot 的注解的更多相关文章
- 国产paozhu c++ web framework 正式版发布
经过大半个月测试修改 paozhu c++ web framework 正式版发布, 1.0.5 release 官方第一次发布正式版,可以用于生产环境. 易用性 超越国外各种 c++ web fra ...
- paozhu c++ web framework 框架原理
paozhu c++ web framework 框架原理 paozhu c++ web framework 使用 asio 网络库,如果用动态库方式还要boost库. paozhu框架 使用两个线程 ...
- java/springboot自定义注解实现AOP
java注解 即是注释了,百度解释:也叫元数据.一种代码级别的说明. 个人理解:就是内容可以被代码理解的注释,一般是一个类. 元数据 也叫元注解,是放在被定义的一个注解类的前面 ,是对注解一种限制. ...
- java springboot@GeneratedValue 注解
springboot中@GeneratedValue作用: (1)@GeneratedValue注解存在的意义主要就是为一个实体生成一个唯一标识的主键.@GeneratedValue提供了主键的生成策 ...
- 【Other】最近在研究的, Java/Springboot/RPC/JPA等
我的Springboot框架,欢迎关注: https://github.com/junneyang/common-web-starter Dubbo-大波-服务化框架 dubbo_百度搜索 Dubbo ...
- 一步步从Spring Framework装配掌握SpringBoot自动装配
目录 Spring Framework模式注解 Spring Framework@Enable模块装配 Spring Framework条件装配 SpringBoot 自动装配 本章总结 Spring ...
- Jena 简介:通过 Jena Semantic Web Framework 在 Jave 应用程序中使用 RDF 模型
简介: RDF 越来越被认为是表示和处理半结构化数据的一种极好选择.本文中,Web 开发人员 Philip McCarthy 向您展示了如何使用 Jena Semantic Web Toolkit,以 ...
- Choosing web framework: ASP.NET MVC vs Django Python vs Ruby on Rails(转载)
来源:http://podlipensky.com/2012/06/choosing-web-framework-asp-net-mvc-vs-django-python-vs-ruby-on-rai ...
- java springboot整合zookeeper入门教程(增删改查)
java springboot整合zookeeper增删改查入门教程 zookeeper的安装与集群搭建参考:https://www.cnblogs.com/zwcry/p/10272506.html ...
- JAVA - SpringBoot项目跨域访问
JAVA - SpringBoot添加支持CORS跨域访问 CORS(Cross-Origin Resource Sharing)“跨域资源共享”,是一个W3C标准,它允许浏览器向跨域服务器发送Aja ...
随机推荐
- java-mybatis-手动分页工具类
使用 List<PhcpSaBankAl> saBankAlList = phcpSaBankAlDao.getBankInfoList(loginUserType.getCityCode ...
- harbor自建https证书生成
1.生成CA证书 # 生成 RSA 私有秘钥 openssl genrsa -out ca-key.pem 4096 # 生成CSR(Certificate Signing Request),CSR和 ...
- 在x86的window安装arm64虚拟机
安装qemu msys2:官网 按照下图步骤下载文件并安装 打开下面终端 根据:qemu官网 在终端执行安装命令:pacman -S mingw-w64-ucrt-x86_64-qemu 下载系统镜像 ...
- Oracle 客户端深度指南:SQL Developer 与 PL/SQL Developer 全面安装使用教程
作为拥有10年Oracle开发经验的资深工程师,我将为您提供一份专业级的客户端工具指南.无论您是初学者还是进阶开发者,本教程都将帮助您高效使用Oracle生态中最强大的两个工具. 一.工具对比与选择建 ...
- [Ynoi2014] 人人本着正义之名
题传 考虑 3/4/5/6 操作,发现本质上是对某段颜色相同的段向左/右拓展. 考虑 1/2 为区间推平操作,其它操作只会减少颜色段,因此总颜色段为 \(O(n+m)\) 的,直接平衡树维护即可. 然 ...
- SQL Prompt 联网限制
SQLPrompt关闭联网_sqlprompt阻止联网_幻欢子的博客-CSDN博客 方法一:修改hosts文件 1.安装SQLPrompt_xxx.exe成功后,编辑修改hosts文件:C:\Wind ...
- 低代码开发平台,可零代码发布API
RestCloud低代码开发平台可以快速的开发企业级前后端分离的业务系统以及基于微服务架构的业务系统.平台通过建立数据模型和业务模型能够无代码快速的发布API服务,同时也能基于数据模型快速生成Java ...
- 运用ETL工具,实现慧穗云数据管理
在数字化时代,数据已成为企业发展的核心驱动力.然而,许多企业在面对庞大的数据量和多样的数据源时,往往面临着数据整合和转换的难题.为了解决这一问题,慧穗云与ETL工具(Extract, Transfor ...
- ETL过程中数据精度不准确问题
最近一位同学在使用Restcloud ETL产品做数据集成,出现数据传输到目标库表后,数据精度不准确问题. 场景为:从oracle源表数据 格式为:number(21,6)将数据同步到mysql目标表 ...
- SciTech-Logic:逻辑学-Introduction to Logic: Irvine - 5.5 传统对当方阵
SciTech-Logic:逻辑学-Introduction to Logic: Irvine - 5.5 传统对当方阵 5.5 传统对当方阵 到目前为止,对直言命题的分析使我们能够进一步研究这些直言 ...