From 5ef81c3997ed125cf514cf54404267945ad22584 Mon Sep 17 00:00:00 2001 From: Alexander Barbosa <40282381+easbarba@users.noreply.github.com> Date: Tue, 6 Aug 2024 04:54:55 -0300 Subject: [PATCH] Fix: fix links of header/footer of pages, and more (#80) --- "CHN/CHN-01-\346\246\202\350\277\260.md" | 4 +- "CHN/CHN-02-\345\256\211\350\243\205.md" | 18 +++--- ...53\351\200\237\345\274\200\345\247\213.md" | 6 +- ...6\345\231\250-\347\256\200\344\273\213.md" | 6 +- ...0\266\345\231\250-HttpSimpleController.md" | 6 +- ...345\210\266\345\231\250-HttpController.md" | 6 +- ...10\266\345\231\250-WebSocketController.md" | 4 +- ...14\350\277\207\346\273\244\345\231\250.md" | 6 +- "CHN/CHN-06-\350\247\206\345\233\276.md" | 6 +- "CHN/CHN-07-\344\274\232\350\257\235.md" | 6 +- ...6\345\272\223-\346\246\202\350\277\260.md" | 6 +- ...5\260\346\215\256\345\272\223-DbClient.md" | 6 +- ...6\345\272\223-\344\272\213\345\212\241.md" | 6 +- ...46\225\260\346\215\256\345\272\223-ORM.md" | 6 +- ...0\346\215\256\345\272\223-FastDbClient.md" | 6 +- ...50\346\211\271\345\244\204\347\220\206.md" | 6 +- ...4\346\226\231-\350\257\267\346\261\202.md" | 6 ++ ...04\347\220\206\347\250\213\345\272\217.md" | 5 ++ .../CHN-10-\346\217\222\344\273\266.md" | 6 +- ...15\347\275\256\346\226\207\344\273\266.md" | 6 +- ...-12-drogon_ctl\345\221\275\344\273\244.md" | 6 +- ...07\351\235\242\347\274\226\347\250\213.md" | 5 +- ...47\350\203\275\346\265\213\350\257\225.md" | 6 +- .../CHN-15-Coz\345\210\206\346\236\220.md" | 6 +- .../CHN-16-Brotli\345\216\213\347\274\251.md" | 6 +- .../CHN-17-\345\215\217\347\250\213.md" | 6 +- CHN/{CHN-17-Redis.md => CHN-18-Redis.md} | 6 +- ...13\350\257\225\346\241\206\346\236\266.md" | 4 +- ...77\347\250\213\346\250\241\345\236\213.md" | 2 +- CHN/CHN-FAQ.md | 2 +- CHN/Home.zh-CN.md | 23 ++++---- ENG/ENG-01-Overview.md | 6 +- ENG/ENG-02-Installation.md | 59 +++++++++++++++---- ENG/ENG-03-Quick-Start.md | 6 +- ENG/ENG-04-0-Controller-Introduction.md | 6 +- ...NG-04-1-Controller-HttpSimpleController.md | 6 +- ENG/ENG-04-2-Controller-HttpController.md | 6 +- ...ENG-04-3-Controller-WebSocketController.md | 6 +- ENG/ENG-05-Middleware-and-Filter.md | 6 +- ENG/ENG-06-View.md | 6 +- ENG/ENG-07-Session.md | 6 +- ENG/ENG-08-0-Database-General.md | 6 +- ENG/ENG-08-1-Database-DbClient.md | 6 +- ENG/ENG-08-2-Database-Transaction.md | 6 +- ENG/ENG-08-3-Database-ORM.md | 6 +- ENG/ENG-08-4-Database-FastDbClient.md | 6 +- ENG/ENG-08-5-Database-auto_batch.md | 6 +- ENG/ENG-09-0-References-request.md | 4 +- ENG/ENG-09-1-File-Handler.md | 5 +- ENG/ENG-10-Plugins.md | 6 +- ENG/ENG-11-Configuration-File.md | 6 +- ENG/ENG-12-drogon_ctl-Command.md | 6 +- ENG/ENG-13-AOP-Aspect-Oriented-Programming.md | 6 +- ENG/ENG-14-Benchmarks.md | 6 +- ENG/ENG-15-Coz.md | 8 +-- ENG/ENG-16-Brotli.md | 4 +- ENG/ENG-17-Coroutines.md | 6 +- ENG/ENG-18-Redis.md | 6 +- ENG/ENG-19-Testing-Framework.md | 4 +- ...-1-Understanding-drogon-threading-model.md | 2 +- ENG/ENG-FAQ.md | 2 +- ENG/Home.md | 28 +++++---- README.md | 4 +- _Sidebar.md | 21 ++++--- index.html | 2 +- package-lock.json | 6 ++ 66 files changed, 312 insertions(+), 168 deletions(-) create mode 100644 "CHN/CHN-09-0-\345\217\202\350\200\203\350\265\204\346\226\231-\350\257\267\346\261\202.md" create mode 100644 "CHN/CHN-09-1-\346\226\207\344\273\266\345\244\204\347\220\206\347\250\213\345\272\217.md" rename "CHN/CHN-09-\346\217\222\344\273\266.md" => "CHN/CHN-10-\346\217\222\344\273\266.md" (96%) rename "CHN/CHN-10-\351\205\215\347\275\256\346\226\207\344\273\266.md" => "CHN/CHN-11-\351\205\215\347\275\256\346\226\207\344\273\266.md" (99%) rename "CHN/CHN-11-drogon_ctl\345\221\275\344\273\244.md" => "CHN/CHN-12-drogon_ctl\345\221\275\344\273\244.md" (97%) rename "CHN/CHN-12-AOP\351\235\242\345\220\221\345\210\207\351\235\242\347\274\226\347\250\213.md" => "CHN/CHN-13-AOP\351\235\242\345\220\221\345\210\207\351\235\242\347\274\226\347\250\213.md" (97%) rename "CHN/CHN-13-\346\200\247\350\203\275\346\265\213\350\257\225.md" => "CHN/CHN-14-\346\200\247\350\203\275\346\265\213\350\257\225.md" (96%) rename "CHN/CHN-14-Coz\345\210\206\346\236\220.md" => "CHN/CHN-15-Coz\345\210\206\346\236\220.md" (90%) rename "CHN/CHN-15-Brotli\345\216\213\347\274\251.md" => "CHN/CHN-16-Brotli\345\216\213\347\274\251.md" (82%) rename "CHN/CHN-16-\345\215\217\347\250\213.md" => "CHN/CHN-17-\345\215\217\347\250\213.md" (98%) rename CHN/{CHN-17-Redis.md => CHN-18-Redis.md} (97%) rename "CHN/CHN-18-\346\265\213\350\257\225\346\241\206\346\236\266.md" => "CHN/CHN-19-\346\265\213\350\257\225\346\241\206\346\236\266.md" (98%) create mode 100644 package-lock.json diff --git "a/CHN/CHN-01-\346\246\202\350\277\260.md" "b/CHN/CHN-01-\346\246\202\350\277\260.md" index 870232c..0b4a525 100644 --- "a/CHN/CHN-01-\346\246\202\350\277\260.md" +++ "b/CHN/CHN-01-\346\246\202\350\277\260.md" @@ -1,4 +1,4 @@ -[English](/ENG/ENG-01-Overview) | [简体中文](/CHN/CHN-01-概述) +[English](/ENG/ENG-01-Overview) **Drogon**是一个基于C++17/20的Http应用框架,使用Drogon可以方便的使用C++构建各种类型的Web应用服务端程序。 @@ -29,4 +29,4 @@ Drogon的主要应用平台是Linux,也支持Mac OS、FreeBSD和Windows。 * 支持插件,可通过配置文件在加载期动态拆装; * 支持内建插入点的AOP -# 02 [安装drogon](/CHN/CHN-02-安装) +# 下一个: [安装drogon](/CHN/CHN-02-安装) diff --git "a/CHN/CHN-02-\345\256\211\350\243\205.md" "b/CHN/CHN-02-\345\256\211\350\243\205.md" index ba04788..6a806ee 100644 --- "a/CHN/CHN-02-\345\256\211\350\243\205.md" +++ "b/CHN/CHN-02-\345\256\211\350\243\205.md" @@ -1,6 +1,6 @@ -[English](/ENG/ENG-02-Installation) | [简体中文](/CHN/CHN-02-安装) +[English](/ENG/ENG-02-Installation) -本节以Ubuntu 18.04, CentOS 7.5, MacOS 12.2为例,简介安装过程,其它系统,大同小异; +本节以Ubuntu 24.04, CentOS 7.5, MacOS 12.2为例,简介安装过程,其它系统,大同小异; ## 系统要求 @@ -29,16 +29,13 @@ ## 系统准备范例 -#### Ubuntu 18.04 +#### Ubuntu 24.04 * 环境 ```shell - sudo apt install git - sudo apt install gcc - sudo apt install g++ - sudo apt install cmake - ``` + sudo apt install git gcc g++ cmake + ``` * jsoncpp @@ -61,8 +58,7 @@ * OpenSSL (可选,提供HTTPS支持) ```shell - sudo apt install openssl - sudo apt install libssl-dev + sudo apt install openssl libssl-dev ``` @@ -472,4 +468,4 @@ pip install conan target_link_libraries(${PROJECT_NAME} PRIVATE drogon) ``` -# 03 [快速开始](/CHN/CHN-03-快速开始) +# 下一个: [快速开始](/CHN/CHN-03-快速开始) diff --git "a/CHN/CHN-03-\345\277\253\351\200\237\345\274\200\345\247\213.md" "b/CHN/CHN-03-\345\277\253\351\200\237\345\274\200\345\247\213.md" index c201e4e..568ccfe 100644 --- "a/CHN/CHN-03-\345\277\253\351\200\237\345\274\200\345\247\213.md" +++ "b/CHN/CHN-03-\345\277\253\351\200\237\345\274\200\345\247\213.md" @@ -1,6 +1,6 @@ -[English](/ENG/ENG-03-Quick-Start) | [简体中文](/CHN/CHN-03-快速开始) +[English](/ENG/ENG-03-Quick-Start) -## 静态网站 +# 静态网站 我们从一个最简单的例子开始,介绍drogon的使用,在这个例子中我们使用命令行工具`drogon_ctl`创建一个工程: @@ -190,4 +190,4 @@ make > **注意: Drogon没有限制控制器(controller)源文件的位置,也可以放在工程目录下,甚至可以在`CMakeLists.txt`中指定到新的目录中,为了方便管理,建议将控制器源文件放在controllers目录。** -# 04.0 [控制器简介](/CHN/CHN-04-0-控制器-简介) +# 下一个: [控制器简介](/CHN/CHN-04-0-控制器-简介) diff --git "a/CHN/CHN-04-0-\346\216\247\345\210\266\345\231\250-\347\256\200\344\273\213.md" "b/CHN/CHN-04-0-\346\216\247\345\210\266\345\231\250-\347\256\200\344\273\213.md" index 4b853ca..476288b 100644 --- "a/CHN/CHN-04-0-\346\216\247\345\210\266\345\231\250-\347\256\200\344\273\213.md" +++ "b/CHN/CHN-04-0-\346\216\247\345\210\266\345\231\250-\347\256\200\344\273\213.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-04-0-Controller-Introduction) | [简体中文](/CHN/CHN-04-控制器-简介) +[English](/ENG/ENG-04-0-Controller-Introduction) + +# 控制器(controller) 控制器(controller)在web应用开发中处于相当重要的地位,它处理浏览器发来的请求,然后生成响应发送给浏览器;drogon框架已经帮我们处理好网络传输、Http协议的解析等等细节,我们只需要关注控制器的逻辑即可;每一个控制器对象可以有一个或者多个处理函数(一般称为handler),函数的接口,一般定义成如下形式: @@ -33,4 +35,4 @@ public: 注册到drogon框架的控制器最多只会有一个实例,在整个应用运行期间都不会销毁,所以,用户可以在控制器类中声明和使用成员变量。注意,控制器的handler被调用时,是在多线程环境下的(当框架的IO线程数配置成大于1的值时),如果需要访问非临时变量,请做好并发保护工作。 -# 04.1 [HttpSimpleController](/CHN/CHN-04-1-控制器-HttpSimpleController) +# 下一个: [HttpSimpleController](/CHN/CHN-04-1-控制器-HttpSimpleController) diff --git "a/CHN/CHN-04-1-\346\216\247\345\210\266\345\231\250-HttpSimpleController.md" "b/CHN/CHN-04-1-\346\216\247\345\210\266\345\231\250-HttpSimpleController.md" index 62baaf9..50f30d8 100644 --- "a/CHN/CHN-04-1-\346\216\247\345\210\266\345\231\250-HttpSimpleController.md" +++ "b/CHN/CHN-04-1-\346\216\247\345\210\266\345\231\250-HttpSimpleController.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-04-1-Controller-HttpSimpleController) | [简体中文](/CHN/CHN-04-1-控制器-HttpSimpleController) +[English](/ENG/ENG-04-1-Controller-HttpSimpleController) + +# 可以由 drogon_ctl 可以由`drogon_ctl`命令行工具快速生成基于`HttpSimpleController`的自定义类的源文件,命令格式如下: @@ -64,4 +66,4 @@ void TestCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, > **上述路径到处理函数的映射是在编译期完成的,事实上,drogon框架也提供了运行期完成映射的接口,运行期映射可以让用户通过配置文件或其它用户接口完成映射或修改映射关系而无需重新编译这个程序(出于性能的考虑,禁止在运行app().run()之后再注册任何映射)。** -# 04.2 [HttpController](/CHN/CHN-04-2-控制器-HttpController) +# 下一个: [HttpController](/CHN/CHN-04-2-控制器-HttpController) diff --git "a/CHN/CHN-04-2-\346\216\247\345\210\266\345\231\250-HttpController.md" "b/CHN/CHN-04-2-\346\216\247\345\210\266\345\231\250-HttpController.md" index 0b8b0b0..6d6bbb7 100644 --- "a/CHN/CHN-04-2-\346\216\247\345\210\266\345\231\250-HttpController.md" +++ "b/CHN/CHN-04-2-\346\216\247\345\210\266\345\231\250-HttpController.md" @@ -1,6 +1,6 @@ -[English](/ENG/ENG-04-2-Controller-HttpController) | [简体中文](/CHN/CHN-04-2-控制器-HttpController) +[English](/ENG/ENG-04-2-Controller-HttpController) -### 生成 +# 生成 可以由`drogon_ctl`命令行工具快速生成基于`HttpController`的自定义类的源文件,命令格式如下: @@ -280,4 +280,4 @@ void User::getInfo(const HttpRequestPtr &req, > **需要注意的是,使用正则表达式要注意匹配冲突(多个不同的handler都匹配),当冲突发生在同一个controller内部时,drogon只会执行第一个handler(先注册进框架的那个handler),当冲突发生在不同controller之间时,执行哪个handler是不确定的,因此用户需要避免这种冲突发生。** -# 04.3 [WebSocketController](/CHN/CHN-04-3-控制器-WebSocketController) +# 下一个: [WebSocketController](/CHN/CHN-04-3-控制器-WebSocketController) diff --git "a/CHN/CHN-04-3-\346\216\247\345\210\266\345\231\250-WebSocketController.md" "b/CHN/CHN-04-3-\346\216\247\345\210\266\345\231\250-WebSocketController.md" index fb29eef..6ee70a8 100644 --- "a/CHN/CHN-04-3-\346\216\247\345\210\266\345\231\250-WebSocketController.md" +++ "b/CHN/CHN-04-3-\346\216\247\345\210\266\345\231\250-WebSocketController.md" @@ -1,4 +1,4 @@ -[English](/ENG/ENG-04-3-Controller-WebSocketController) | [简体中文](/CHN/CHN-04-3-控制器-WebSocketController) +[English](/ENG/ENG-04-3-Controller-WebSocketController) 顾名思义,`WebSocketController`用于处理websocket逻辑。websocket是基于HTTP的一种长连接方案,在websocket建立之初,有一次HTTP格式的请求和应答交换,建立完成后,所有的消息在websocket上传输,消息由固定的格式包装,但消息的内容和收发次序没有任何要求,完全由用户定义。 @@ -148,4 +148,4 @@ void EchoWebsock::handleConnectionClosed(const WebSocketConnectionPtr &wsConnPtr any *getMutableContext(); ``` -# 05 [中间件和过滤器](/CHN/CHN-05-中间件和过滤器) +# 下一个: [中间件和过滤器](/CHN/CHN-05-中间件和过滤器) diff --git "a/CHN/CHN-05-\344\270\255\351\227\264\344\273\266\345\222\214\350\277\207\346\273\244\345\231\250.md" "b/CHN/CHN-05-\344\270\255\351\227\264\344\273\266\345\222\214\350\277\207\346\273\244\345\231\250.md" index ee613e0..d34819c 100644 --- "a/CHN/CHN-05-\344\270\255\351\227\264\344\273\266\345\222\214\350\277\207\346\273\244\345\231\250.md" +++ "b/CHN/CHN-05-\344\270\255\351\227\264\344\273\266\345\222\214\350\277\207\346\273\244\345\231\250.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-05-Middleware-and-Filter) | [简体中文](/CHN/CHN-05-中间件和过滤器) +[English](/ENG/ENG-05-Middleware-and-Filter) + +# 中间件 中间件(middleware)和过滤器(filter)可以帮助用户提高编程效率,在HttpController的[例子](/CHN/CHN-04-2-控制器-HttpController)中,getInfo方法在返回用户信息之前应该先校验用户是否登录,我们把这个逻辑写在getInfo方法里当然是可以的,但是,很显然,校验用户登录属于通用逻辑,很多接口都将用到,应该把它单独提取出来,再配置到调用handler之前,这就是filter的作用。 @@ -98,4 +100,4 @@ drogon内置了如下常用过滤器: > **注意: 如果中间件/过滤器定义在命名空间里,注册时必须把命名空间写全** -# 06 [视图](/CHN/CHN-06-视图) +# 下一个: [视图](/CHN/CHN-06-视图) diff --git "a/CHN/CHN-06-\350\247\206\345\233\276.md" "b/CHN/CHN-06-\350\247\206\345\233\276.md" index 2f020a1..332ea45 100644 --- "a/CHN/CHN-06-\350\247\206\345\233\276.md" +++ "b/CHN/CHN-06-\350\247\206\345\233\276.md" @@ -1,6 +1,6 @@ -[English](/ENG/ENG-06-View) | [简体中文](/CHN/CHN-06-视图) +[English](/ENG/ENG-06-View) -### 视图介绍 +# 视图介绍 虽然目前前端渲染技术大行其道,使后端应用服务只需要返回相应数据给前端即可,不过,一个好的web框架还是应该提供后端渲染技术,使服务端程序可以动态生成HTML页面。视图(View)可以帮助使用者生成这些页面,顾名思义,它只负责做跟展示相关的工作,而复杂的业务逻辑都应该交给控制器完成。 @@ -155,4 +155,4 @@ void enableDynamicViewsLoading(const std::vector &libPaths); > **注意: 如果加载时遇到`symbol not found`错误,请使用`cmake .. -DCMAKE_ENABLE_EXPORTS=on`或取消CMakeLists.txt最后一行对`set_property(TARGET ${PROJECT_NAME} PROPERTY ENABLE_EXPORTS ON)`的注释,并重新编译你的工程** -# 07 [会话](/CHN/CHN-07-会话) +# 下一个: [会话](/CHN/CHN-07-会话) diff --git "a/CHN/CHN-07-\344\274\232\350\257\235.md" "b/CHN/CHN-07-\344\274\232\350\257\235.md" index 8ad0022..19dfdde 100644 --- "a/CHN/CHN-07-\344\274\232\350\257\235.md" +++ "b/CHN/CHN-07-\344\274\232\350\257\235.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-07-Session) | [简体中文](/CHN/CHN-07-会话) +[English](/ENG/ENG-07-Session) + +# 会话(Session) `会话(Session)`是web应用的重要概念,用于在服务端保存客户端的状态,一般和浏览器的`cookie`配合,drogon提供了对会话的支持。drogon默认**关闭**会话选择,你也可以通过如下接口关闭或打开: @@ -97,4 +99,4 @@ drogon::HttpAppFramework::instance().enableSession(1200); 用cmake重新编译整个工程,运行目标程序webapp,就可以通过浏览器看到效果了。 -# [数据库](/CHN/CHN-08-0-数据库-概述) +# 下一个: [数据库](/CHN/CHN-08-0-数据库-概述) diff --git "a/CHN/CHN-08-0-\346\225\260\346\215\256\345\272\223-\346\246\202\350\277\260.md" "b/CHN/CHN-08-0-\346\225\260\346\215\256\345\272\223-\346\246\202\350\277\260.md" index e9d75cc..4dfb666 100644 --- "a/CHN/CHN-08-0-\346\225\260\346\215\256\345\272\223-\346\246\202\350\277\260.md" +++ "b/CHN/CHN-08-0-\346\225\260\346\215\256\345\272\223-\346\246\202\350\277\260.md" @@ -1,6 +1,6 @@ -[English](/ENG/ENG-08-0-Database-General) | [简体中文](/CHN/CHN-08-0-数据库-概述) +[English](/ENG/ENG-08-0-Database-General) -### 概述 +# 概述 **Drogon**内置了数据库读写引擎,对数据库连接的操作基于non-blocking I/O技术实现,因此,从底层到上层接口,都是高效率的非阻塞异步方式,保证了Drogon对高并发性能的追求。目前,Drogon支持PostgreSQL和MySQL数据库,如果要使用数据库,开发系统必须先安装相应数据库的开发环境,Drogon会自动探测这些库的头文件和库文件,编译相应的部分。数据库开发环境的准备,参见[安装数据库环境](/CHN/CHN-02-安装#数据库环境)。 @@ -24,4 +24,4 @@ Drogon的数据库基本操作对象是`DbClient`(这是一个抽象类,用户 Drogon也提供了对**ORM**的支持,用户可以通过drogon_ctl读取数据库中的表,并生成对应的model对象类源码,然后,通过`Mapper`类模板完成这些对象的数据库操作,为标准的数据操作提供了简单便捷的接口,使用户可以不用自己写sql语句就可以完成对表的增删改查。关于**ORM**,请参阅[ORM](/CHN/CHN-08-3-数据库-ORM)。 -# 08.1 [DbClient](/CHN/CHN-08-1-数据库-DbClient) +# 下一个: [DbClient](/CHN/CHN-08-1-数据库-DbClient) diff --git "a/CHN/CHN-08-1-\346\225\260\346\215\256\345\272\223-DbClient.md" "b/CHN/CHN-08-1-\346\225\260\346\215\256\345\272\223-DbClient.md" index c81cad8..f75ae75 100644 --- "a/CHN/CHN-08-1-\346\225\260\346\215\256\345\272\223-DbClient.md" +++ "b/CHN/CHN-08-1-\346\225\260\346\215\256\345\272\223-DbClient.md" @@ -1,6 +1,6 @@ -[English](/ENG/ENG-08-1-Database-DbClient) | [简体中文](/CHN/CHN-08-1-数据库-DbClient) +[English](/ENG/ENG-08-1-Database-DbClient) -### 构建DbClient +# 构建 DbClient 构造DbClient对象有两种途径,一个是通过DbClient类的静态方法,在DbClient.h头文件可以看到定义,如下: @@ -252,4 +252,4 @@ internal::SqlBinder operator<<(const std::string &sql); 它虽然也提供阻塞的接口,这种接口只是阻塞调用者线程,只要调用者线程不是EventLoop线程,就不会影响EventLoop线程的正常运转。回调函数被调用时,回调内的程序是运行在EventLoop线程的,所以,不要在回调内部进行任何阻塞操作,否则会影响数据库的并发,熟悉non-blocking I/O编程的人都应该明白这个约束。 -# 08.2 [事务](/CHN/CHN-08-2-数据库-事务) +# 下一个: [事务](/CHN/CHN-08-2-数据库-事务) diff --git "a/CHN/CHN-08-2-\346\225\260\346\215\256\345\272\223-\344\272\213\345\212\241.md" "b/CHN/CHN-08-2-\346\225\260\346\215\256\345\272\223-\344\272\213\345\212\241.md" index d44ccf5..d6a8ca0 100644 --- "a/CHN/CHN-08-2-\346\225\260\346\215\256\345\272\223-\344\272\213\345\212\241.md" +++ "b/CHN/CHN-08-2-\346\225\260\346\215\256\345\272\223-\344\272\213\345\212\241.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-08-2-Database-Transaction) | [简体中文](/CHN/CHN-08-2-数据库-事务) +[English](/ENG/ENG-08-2-Database-Transaction) + +# 数据库 - 事务 > **事务**是关系型数据库的重要特性,Drogon通过`Transaction`类提供了对事务的支持。 @@ -83,4 +85,4 @@ void newTransactionAsync(const std::function(); 所有插件在run()接口内初始化完毕,在应用程序退出时才销毁,因此,插件的生命周期几乎和应用程序等同,这也是getPlugin()接口不需要返回智能指针的原因。 -# 10 [配置文件](/CHN/CHN-10-配置文件) +# 下一个: [配置文件](/CHN/CHN-11-配置文件) diff --git "a/CHN/CHN-10-\351\205\215\347\275\256\346\226\207\344\273\266.md" "b/CHN/CHN-11-\351\205\215\347\275\256\346\226\207\344\273\266.md" similarity index 99% rename from "CHN/CHN-10-\351\205\215\347\275\256\346\226\207\344\273\266.md" rename to "CHN/CHN-11-\351\205\215\347\275\256\346\226\207\344\273\266.md" index eb2d808..039c941 100644 --- "a/CHN/CHN-10-\351\205\215\347\275\256\346\226\207\344\273\266.md" +++ "b/CHN/CHN-11-\351\205\215\347\275\256\346\226\207\344\273\266.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-11-Configuration-File) | [简体中文](/CHN/CHN-10-配置文件) +[English](/ENG/ENG-11-Configuration-File) + +# 配置文件 你可以通过DrogonAppFramework实例的多个接口配置各种参数来控制Http服务端的某些行为。不过,使用配置文件是更好的方式,原因如下: @@ -355,4 +357,4 @@ int main() "pipelining_requests": 0 ``` -# 11 [drogon_ctl 命令](/CHN/CHN-11-drogon_ctl命令) +# 下一个: [drogon_ctl 命令](/CHN/CHN-12-drogon_ctl命令) diff --git "a/CHN/CHN-11-drogon_ctl\345\221\275\344\273\244.md" "b/CHN/CHN-12-drogon_ctl\345\221\275\344\273\244.md" similarity index 97% rename from "CHN/CHN-11-drogon_ctl\345\221\275\344\273\244.md" rename to "CHN/CHN-12-drogon_ctl\345\221\275\344\273\244.md" index 2b24b41..a476079 100644 --- "a/CHN/CHN-11-drogon_ctl\345\221\275\344\273\244.md" +++ "b/CHN/CHN-12-drogon_ctl\345\221\275\344\273\244.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-12-drogon_ctl-Command) | [简体中文](/CHN/CHN-11-drogon_ctl命令) +[English](/ENG/ENG-12-drogon_ctl-Command) + +# drogon_ctl **Drogon**框架编译安装后,一个命令行程序 `drogon_ctl` 也同时被安装于系统,为了方便,还安装了一个完全一样的副本 `dg_ctl`。用户可以按喜好自行选用。 @@ -169,4 +171,4 @@ dg_ctl press -n1000000 -t4 -c1000 -q http://localhost:8080/ dg_ctl press -n 1000000 -t 4 -c 1000 https://www.domain.com/path/to/be/tested ``` -# 12 [AOP 面向切面编程](/CHN/CHN-12-AOP面向切面编程) +# 下一个: [AOP 面向切面编程](/CHN/CHN-13-AOP面向切面编程) diff --git "a/CHN/CHN-12-AOP\351\235\242\345\220\221\345\210\207\351\235\242\347\274\226\347\250\213.md" "b/CHN/CHN-13-AOP\351\235\242\345\220\221\345\210\207\351\235\242\347\274\226\347\250\213.md" similarity index 97% rename from "CHN/CHN-12-AOP\351\235\242\345\220\221\345\210\207\351\235\242\347\274\226\347\250\213.md" rename to "CHN/CHN-13-AOP\351\235\242\345\220\221\345\210\207\351\235\242\347\274\226\347\250\213.md" index 38ef530..f959381 100644 --- "a/CHN/CHN-12-AOP\351\235\242\345\220\221\345\210\207\351\235\242\347\274\226\347\250\213.md" +++ "b/CHN/CHN-13-AOP\351\235\242\345\220\221\345\210\207\351\235\242\347\274\226\347\250\213.md" @@ -1,5 +1,6 @@ [English](/ENG/ENG-13-AOP-Aspect-Oriented-Programming) -| [简体中文](/CHN/CHN-12-AOP面向切面编程) + +## 面向切面编程 - AOP AOP(面向切面编程)是实现程序功能的统一维护的一种技术。利用AOP可以对业务逻辑的各个部分进行隔离,从而使得业务逻辑各部分之间的耦合度降低,提高程序的可重用性,同时提高了开发的效率。 @@ -26,4 +27,4 @@ Drogon提供了7个插入点供用户使用,当应用程序运行至插入点 ![](images/AOP.png) -# 13 [性能测试](/CHN/CHN-13-性能测试) +# 下一个: [性能测试](/CHN/CHN-14-性能测试) diff --git "a/CHN/CHN-13-\346\200\247\350\203\275\346\265\213\350\257\225.md" "b/CHN/CHN-14-\346\200\247\350\203\275\346\265\213\350\257\225.md" similarity index 96% rename from "CHN/CHN-13-\346\200\247\350\203\275\346\265\213\350\257\225.md" rename to "CHN/CHN-14-\346\200\247\350\203\275\346\265\213\350\257\225.md" index e3ef21b..c1a30fe 100644 --- "a/CHN/CHN-13-\346\200\247\350\203\275\346\265\213\350\257\225.md" +++ "b/CHN/CHN-14-\346\200\247\350\203\275\346\265\213\350\257\225.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-14-Benchmarks) | [简体中文](/CHN/CHN-13-性能测试) +[English](/ENG/ENG-14-Benchmarks) + +## 性能测试 作为C++的Http应用框架,性能应该是关注的重点之一,本节介绍Drogon的简单测试和成绩; @@ -45,4 +47,4 @@ void BenchmarkCtrl::asyncHandleHttpRequest(const HttpRequestPtr &req, std::funct ![测试截图](images/benchmark.png) -# 14 [Coz 分析](/CHN/CHN-14-Coz分析) +# 下一个: [Coz 分析](/CHN/CHN-15-Coz分析) diff --git "a/CHN/CHN-14-Coz\345\210\206\346\236\220.md" "b/CHN/CHN-15-Coz\345\210\206\346\236\220.md" similarity index 90% rename from "CHN/CHN-14-Coz\345\210\206\346\236\220.md" rename to "CHN/CHN-15-Coz\345\210\206\346\236\220.md" index 2c02d77..d037299 100644 --- "a/CHN/CHN-14-Coz\345\210\206\346\236\220.md" +++ "b/CHN/CHN-15-Coz\345\210\206\346\236\220.md" @@ -1,6 +1,6 @@ -[English](/ENG/ENG-15-Coz) | [简体中文](/CHN/CHN-14-Coz分析) +[English](/ENG/ENG-15-Coz) -## 使用coz进行因果分析 +# 分析 - Coz 使用coz,您可以分析两件事: @@ -23,4 +23,4 @@ Coz还支持使用 `--source-scope ` 或 `-s ` 等其他方法 - [Git repo](https://github.com/plasma-umass/coz) - [Coz whitepaper](https://arxiv.org/pdf/1608.03676v1.pdf) -# 15 [Brotli 压缩](/CHN/CHN-15-Brotil-压缩) +# 下一个: [Brotli 压缩](/CHN/CHN-16-Brotli压缩) diff --git "a/CHN/CHN-15-Brotli\345\216\213\347\274\251.md" "b/CHN/CHN-16-Brotli\345\216\213\347\274\251.md" similarity index 82% rename from "CHN/CHN-15-Brotli\345\216\213\347\274\251.md" rename to "CHN/CHN-16-Brotli\345\216\213\347\274\251.md" index 528992d..f874b4d 100644 --- "a/CHN/CHN-15-Brotli\345\216\213\347\274\251.md" +++ "b/CHN/CHN-16-Brotli\345\216\213\347\274\251.md" @@ -1,6 +1,6 @@ -[English](/ENG/ENG-16-Brotli) | [简体中文](/CHN/CHN-15-Brotli压缩) +[English](/ENG/ENG-16-Brotli) -## Brotli压缩 +# 压缩 - Brotli 如果存在相应的brotli压缩文件,Drogon开箱即用地支持这些brotli静态压缩文件。 @@ -12,4 +12,4 @@ 不打算使用brotli静态压缩的用户,可能希望摆脱brotli额外的“同名文件检查”,可通过在“config.json”中将“br_static”设置为“false”。 -# 16 [协程]](/CHN/CHN-16-协程) +# 下一个: [协程](/CHN/CHN-17-协程) diff --git "a/CHN/CHN-16-\345\215\217\347\250\213.md" "b/CHN/CHN-17-\345\215\217\347\250\213.md" similarity index 98% rename from "CHN/CHN-16-\345\215\217\347\250\213.md" rename to "CHN/CHN-17-\345\215\217\347\250\213.md" index b4e5c81..bc1c05a 100644 --- "a/CHN/CHN-16-\345\215\217\347\250\213.md" +++ "b/CHN/CHN-17-\345\215\217\347\250\213.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-17-Coroutines) | [简体中文](/CHN/CHN-16-协程) +[English](/ENG/ENG-17-Coroutines) + +# 协程 Drogon从1.4版本开始支持[C++ coroutines][1](协程)。 它提供了扁平化异步执行控制流的方法, 比如,避免著名的`回调地狱callback hell`. 通过协程, 异步编程将像同步编程一样简单(同时保持了异步程序的高性能)。 @@ -166,4 +168,4 @@ app.registerHandler("/num_users", [1]: https://en.cppreference.com/w/cpp/language/coroutines -# 17 [Redis](/CHN/CHN-17-Redis) +# 下一个: [Redis](/CHN/CHN-18-Redis) diff --git a/CHN/CHN-17-Redis.md b/CHN/CHN-18-Redis.md similarity index 97% rename from CHN/CHN-17-Redis.md rename to CHN/CHN-18-Redis.md index 0422e98..e8e3ae4 100644 --- a/CHN/CHN-17-Redis.md +++ b/CHN/CHN-18-Redis.md @@ -1,4 +1,6 @@ -[English](/ENG/ENG-18-Redis) | [简体中文](/CHN/CHN-17-Redis) +[English](/ENG/ENG-18-Redis) + +# Redis Drogon支持Redis,Redis是一种非常快速的内存数据存储。 可以用作数据库缓存或消息代理。 与Drogon中其他组件一樣,Redis的操作是异步的。 这确保了Drogon即使在重负载下也能以非常高的并发性运行。 @@ -117,4 +119,4 @@ catch(const std::exception& e) } ``` -# [测试框架](/CHN/CHN-18-测试框架) +# 下一个: [测试框架](/CHN/CHN-19-测试框架) diff --git "a/CHN/CHN-18-\346\265\213\350\257\225\346\241\206\346\236\266.md" "b/CHN/CHN-19-\346\265\213\350\257\225\346\241\206\346\236\266.md" similarity index 98% rename from "CHN/CHN-18-\346\265\213\350\257\225\346\241\206\346\236\266.md" rename to "CHN/CHN-19-\346\265\213\350\257\225\346\241\206\346\236\266.md" index 8b7c3a6..e45c377 100644 --- "a/CHN/CHN-18-\346\265\213\350\257\225\346\241\206\346\236\266.md" +++ "b/CHN/CHN-19-\346\265\213\350\257\225\346\241\206\346\236\266.md" @@ -1,4 +1,6 @@ -[English](/ENG/ENG-19-Testing-Framework) | [简体中文](/CHN/CHN-18-测试框架) +[English](/ENG/ENG-19-Testing-Framework) + +# 测试框架 DrogonTest是一个内置在Drogon中的最小测试框架,可实现简单的异步测试和同步测试。 它用于Drogon自己的单元测试和集成测试。 但也可用于测试使用Drogon构建的应用程序。 DrogonTest的语法受到[GTest](https://github.com/google/googletest)和[Catch2](https://github.com/catchorg/Catch2)的启发。 diff --git "a/CHN/CHN-FAQ-1-\347\272\277\347\250\213\346\250\241\345\236\213.md" "b/CHN/CHN-FAQ-1-\347\272\277\347\250\213\346\250\241\345\236\213.md" index 1515343..c9f176d 100644 --- "a/CHN/CHN-FAQ-1-\347\272\277\347\250\213\346\250\241\345\236\213.md" +++ "b/CHN/CHN-FAQ-1-\347\272\277\347\250\213\346\250\241\345\236\213.md" @@ -1,4 +1,4 @@ -[English](CHS-FAQ-1-Understanding-drogon-threading-model.md) | [简体中文](/CHN/CHN-FAQ-1-线程模型.md) +[English](CHS-FAQ-1-Understanding-drogon-threading-model.md) # 理解Drogon's的线程模型 diff --git a/CHN/CHN-FAQ.md b/CHN/CHN-FAQ.md index b1f85b9..246b0b2 100644 --- a/CHN/CHN-FAQ.md +++ b/CHN/CHN-FAQ.md @@ -1,4 +1,4 @@ -[English](/ENG/ENG-FAQ) | [简体中文](/CHN/CHN-FAQ) +[English](/ENG/ENG-FAQ) # FAQ diff --git a/CHN/Home.zh-CN.md b/CHN/Home.zh-CN.md index 1a2e280..206ac94 100644 --- a/CHN/Home.zh-CN.md +++ b/CHN/Home.zh-CN.md @@ -1,4 +1,4 @@ -[English](Home) | [简体中文](Home.zh-CN) +[English](Home) ### [欢迎使用 Drogon!](/CHN/CHN-01-概述) @@ -65,16 +65,19 @@ * [many to many](/CHN/CHN-08-3-数据库-ORM#many-to-many) * [FastDbClient](/CHN/CHN-08-4-数据库-FastDbClient) * [自动批处理模式](/CHN/CHN-08-5-数据库-自动批处理) -* [插件](/CHN/CHN-09-插件) -* [配置文件](/CHN/CHN-10-配置文件) -* [drogon_ctl命令](/CHN/CHN-11-drogon_ctl命令) -* [AOP面向切面编程](/CHN/CHN-12-AOP面向切面编程) -* [性能测试](/CHN/CHN-13-性能测试) -* [协程](/CHN/CHN-16-协程) -* [Redis](/CHN/CHN-17-Redis) -* [测试框架](/CHN/CHN-18-测试框架) +* [参考资料 - 请求](/CHN/CHN-09-0-参考资料-请求) +* [文件处理程序](/CHN/CHN-09-1-文件处理程序) +* [插件](/CHN/CHN-10-插件) +* [配置文件](/CHN/CHN-11-配置文件) +* [drogon_ctl命令](/CHN/CHN-12-drogon_ctl命令) +* [AOP面向切面编程](/CHN/CHN-13-AOP面向切面编程) +* [性能测试](/CHN/CHN-14-性能测试) +* [Coz 分析](/CHN/CHN-15-Coz分析) +* [Brotli 压缩](/CHN/CHN-16-Brotli压缩) +* [协程](/CHN/CHN-17-协程) +* [Redis](/CHN/CHN-18-Redis) +* [测试框架](/CHN/CHN-19-测试框架) * [FAQ](/CHN/CHN-FAQ) * [drogon的线程模型](/CHN/CHN-FAQ-1-线程模型) - ### 想要为此wiki做出贡献,请访问[drogon-docs](https://github.com/drogonframework/drogon-docs)仓库。 diff --git a/ENG/ENG-01-Overview.md b/ENG/ENG-01-Overview.md index 57439b6..3010a18 100644 --- a/ENG/ENG-01-Overview.md +++ b/ENG/ENG-01-Overview.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-01-概述) +##### Other languages: [简体中文](/CHN/CHN-01-概述) + +# Overview **Drogon** is a C++17/20-based HTTP application framework. Drogon can be used to easily build various types of web application server programs using C++. @@ -31,4 +33,4 @@ Its main features are as follows: * Support plugins which can be installed by the configuration file at load time; * Support AOP with build-in joinpoints. -# Next: [Install drogon](/drogon-docs/#/ENG/ENG-02-Installation) +# Next: [Install drogon](/ENG/ENG-02-Installation) diff --git a/ENG/ENG-02-Installation.md b/ENG/ENG-02-Installation.md index d94af76..992011b 100644 --- a/ENG/ENG-02-Installation.md +++ b/ENG/ENG-02-Installation.md @@ -1,6 +1,8 @@ -##### Other languages: [简体中文](drogon-docs/#/CHN/CHN-02-安装) +##### Other languages: [简体中文](/CHN/CHN-02-安装) -This section takes Ubuntu 18.04, CentOS 7.5, MacOS 12.2 as an example to introduce the installation process. Other systems are similar; +# Installation + +This section takes Ubuntu 24.04, CentOS 7.5, MacOS 12.2 as an example to introduce the installation process. Other systems are similar; ## System Requirements @@ -30,15 +32,12 @@ This section takes Ubuntu 18.04, CentOS 7.5, MacOS 12.2 as an example to introdu ## System Preparation Examples -#### Ubuntu 18.04 +#### Ubuntu 24.04 * Environment ```shell - sudo apt install git - sudo apt install gcc - sudo apt install g++ - sudo apt install cmake + sudo apt install git gcc g++ cmake ``` * jsoncpp @@ -62,8 +61,39 @@ This section takes Ubuntu 18.04, CentOS 7.5, MacOS 12.2 as an example to introdu * OpenSSL (Optional, if you want to support HTTPS) ```shell - sudo apt install openssl - sudo apt install libssl-dev + sudo apt install openssl libssl-dev + ``` + +#### Arch Linux + +* Environment + + ```shell + sudo pacman -S git gcc make cmake + ``` + +* jsoncpp + + ```shell + sudo pacman -S jsoncpp + ``` + +* uuid + + ```shell + sudo pacman -S uuid + ``` + +* zlib + + ```shell + sudo pacman -S zlib + ``` + +* OpenSSL (Optional, if you want to support HTTPS) + + ```shell + sudo pacman -S openssl libssl ``` #### CentOS 7.5 @@ -211,6 +241,8 @@ Create`conanfile.txt`and add the following content to it: * `ubuntu 16`: `sudo apt-get install postgresql-server-dev-all` * `ubuntu 18`: `sudo apt-get install postgresql-all` + * `ubuntu 24`: `sudo apt-get install postgresql-all` + * `arch`: `sudo pacman -S postgresql` * `centOS 7`: `yum install postgresql-devel` * `MacOS`: `brew install postgresql` * `Windows conanfile`: `libpq/13.4` @@ -221,7 +253,9 @@ Create`conanfile.txt`and add the following content to it: MariaDB installation is as follows: - * `ubuntu`: `sudo apt install libmariadbclient-dev` + * `ubuntu 18.04`: `sudo apt install libmariadbclient-dev` + * `ubuntu 24.04`: `sudo apt install libmariadb-dev-compat libmariadb-dev` + * `arch`: `sudo pacman -S mariadb` * `centOS 7`: `yum install mariadb-devel` * `MacOS`: `brew install mariadb` * `Windows conanfile`: `libmariadb/3.1.13` @@ -229,12 +263,14 @@ Create`conanfile.txt`and add the following content to it: * #### Sqlite3 * `ubuntu`: `sudo apt-get install libsqlite3-dev` + * `arch`: `sudo pacman -S sqlite3` * `centOS`: `yum install sqlite-devel` * `MacOS`: `brew install sqlite3` * `Windows conanfile`: `sqlite3/3.36.0` * #### Redis * `ubuntu`: `sudo apt-get install libhiredis-dev` + * `ubuntu`: `sudo pacman -S redis` * `centOS`: `yum install hiredis-devel` * `MacOS`: `brew install hiredis` * `Windows conanfile`: `hiredis/1.0.0` @@ -431,6 +467,7 @@ Assuming that the above environment and library dependencies are all ready, the buildInputs = with pkgs; [ drogon ]; + } ``` @@ -481,4 +518,4 @@ Assuming that the above environment and library dependencies are all ready, the target_link_libraries(${PROJECT_NAME} PRIVATE drogon) ``` -# Next: [Quick Start](/drogon-docs/#/ENG/ENG-03-Quick-Start) +# Next: [Quick Start](/ENG/ENG-03-Quick-Start) diff --git a/ENG/ENG-03-Quick-Start.md b/ENG/ENG-03-Quick-Start.md index 26913c8..136dd49 100644 --- a/ENG/ENG-03-Quick-Start.md +++ b/ENG/ENG-03-Quick-Start.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-03-快速开始) +##### Other languages: [简体中文](/CHN/CHN-03-快速开始) + +# Quick Start ## Static Site @@ -194,4 +196,4 @@ We see that adding a controller to an application is very simple. You only need > **Note: Drogon has no restrictions on the location of the controller source files. You could also save them in "./" (the project root directory), or you could even define a new directory in `CMakeLists.txt`. It is recommended to use the controllers directory for the convenience of management.** -# Next: [drogon_ctl Command](/drogon-docs/#/ENG/ENG-04-0-Controller-Introduction) +# Next: [Controller - Introduction](/ENG/ENG-04-0-Controller-Introduction) diff --git a/ENG/ENG-04-0-Controller-Introduction.md b/ENG/ENG-04-0-Controller-Introduction.md index 5226494..9369adf 100644 --- a/ENG/ENG-04-0-Controller-Introduction.md +++ b/ENG/ENG-04-0-Controller-Introduction.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-04-0-控制器-简介) +##### Other languages: [简体中文](/CHN/CHN-04-控制器-简介) + +# Controller - Introduction The controller is very important in web application development. This is where we will define our URLs, which HTTP methods are allowed, which [filters](/ENG//ENG/ENG-06-Middleware-and-Filter) will be applied and how requests will be processed and responded to. The drogon framework has helped us to handle the network transmission, Http protocol analysis and so on. We only need to pay attention to the logic of the controller; each controller object can have one or more processing functions (generally called handlers), and the interface of the function is generally defined as follows: @@ -33,4 +35,4 @@ public: A controller registered to a drogon framework will have at most only one instance and will not be destroyed during the entire application run, so users can declare and use member variables in the controller class. Note that when the handler of the controller is called, it is in a multi-threaded environment (when the number of IO threads of the framework is configured to be greater than 1), if you need to access non-temporary variables, please do the concurrent protection work. -# Next: [HttpSimpleController](/drogon-docs/#/ENG/ENG-04-1-Controller-HttpSimpleController) +# Next: [HttpSimpleController](/ENG/ENG-04-1-Controller-HttpSimpleController) diff --git a/ENG/ENG-04-1-Controller-HttpSimpleController.md b/ENG/ENG-04-1-Controller-HttpSimpleController.md index 3f2bbde..81044d7 100644 --- a/ENG/ENG-04-1-Controller-HttpSimpleController.md +++ b/ENG/ENG-04-1-Controller-HttpSimpleController.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-04-1-控制器-HttpSimpleController) +##### Other languages: [简体中文](/CHN/CHN-04-1-控制器-HttpSimpleController) + +# Controller - HttpSimpleController You could use the `drogon_ctl` command line tool to quickly generate custom controller class source files based on `HttpSimpleController`. The command format is as bellow: @@ -64,4 +66,4 @@ You could define an HttpResponse class variable, and then use the callback() to > **The mapping from the above path to the handler is done at compile time. In fact, the drogon framework also provides an interface for runtime completion mapping. The runtime mapping allows the user to map or modify the mapping through configuration files or other user interfaces without recompiling this program (For performance reasons, it is forbidden to add any controller mapping after running the app().run() method).** -# Next: [HttpController](/drogon-docs/#/ENG/ENG-04-2-Controller-HttpController) +# Next: [HttpController](/ENG/ENG-04-2-Controller-HttpController) diff --git a/ENG/ENG-04-2-Controller-HttpController.md b/ENG/ENG-04-2-Controller-HttpController.md index 659ef09..093ec68 100644 --- a/ENG/ENG-04-2-Controller-HttpController.md +++ b/ENG/ENG-04-2-Controller-HttpController.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-04-2-控制器-HttpController) +##### Other languages: [简体中文](/CHN/CHN-04-2-控制器-HttpController) + +# Controller - HttpController ### Generation @@ -279,4 +281,4 @@ Each `HttpController` class can define many Http request handlers. Since the num > **It should be noted that when using regular expressions, you should pay attention to matching conflicts (multiple different handlers are matched). When conflicts happen in the same controller, drogon will only execute the first handler (the one registered in the framework first). When conflicts happen between different controllers, it is uncertain which handler will be executed. Therefore, users need to avoid these conflicts.** -# Next: [WebSocketController](/drogon-docs/#/ENG/ENG-04-3-Controller-WebSocketController) +# Next: [WebSocketController](/ENG/ENG-04-3-Controller-WebSocketController) diff --git a/ENG/ENG-04-3-Controller-WebSocketController.md b/ENG/ENG-04-3-Controller-WebSocketController.md index a3f0780..bb02aa0 100644 --- a/ENG/ENG-04-3-Controller-WebSocketController.md +++ b/ENG/ENG-04-3-Controller-WebSocketController.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-04-3-控制器-WebSocketController) +##### Other languages: [简体中文](/CHN/CHN-04-3-控制器-WebSocketController) + +# Controller - WebSockerController As the name implies, `WebSocketController` is used to process websocket logic. Websocket is a persistent HTTP-based connection scheme. At the beginning of the websocket, there is an HTTP format request and response exchange. After the websocket connection is established, all messages are transmitted on the websocket. The message is wrapped in a fixed format. There is no limit to the message content and the order in which messages are transmitted. @@ -150,4 +152,4 @@ void EchoWebsock::handleConnectionClosed(const WebSocketConnectionPtr &wsConnPtr any *getMutableContext(); ``` -# Next: [Middleware and Filter](/drogon-docs/#/ENG/ENG-05-Middleware-and-Filter) +# Next: [Middleware and Filter](/ENG/ENG-05-Middleware-and-Filter) diff --git a/ENG/ENG-05-Middleware-and-Filter.md b/ENG/ENG-05-Middleware-and-Filter.md index 85b3215..8ad2edb 100644 --- a/ENG/ENG-05-Middleware-and-Filter.md +++ b/ENG/ENG-05-Middleware-and-Filter.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-05-中间件和过滤器) +##### Other languages: [简体中文](/CHN/CHN-05-中间件和过滤器) + +# Middleware and Filter In HttpController's [example](/ENG//ENG/ENG-04-2-Controller-HttpController), the getInfo method should check whether the user is logged in before returning the user's information. We can write this logic in the getInfo method, but obviously, checking the user's login membership is general logic which will be used by many interfaces, it should be extracted separately and configured before calling handler, which is what filters do. @@ -100,4 +102,4 @@ Drogon contains the following common filters: > **Note: If the middleware/filter is defined in the namespace, you must write the namespace completely when you register it.** -# Next: [View](/drogon-docs/#/ENG/ENG-06-View) +# Next: [View](/ENG/ENG-06-View) diff --git a/ENG/ENG-06-View.md b/ENG/ENG-06-View.md index 9077b0e..8d28ee1 100644 --- a/ENG/ENG-06-View.md +++ b/ENG/ENG-06-View.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-06-视图) +##### Other languages: [简体中文](/CHN/CHN-06-视图) + +# View ### Views Introduction @@ -151,4 +153,4 @@ Obviously, this function depends on the development environment. If both drogon > **Note: If a `symbol not found` error occurs while loading a dynamic view, please use the `cmake .. -DCMAKE_ENABLE_EXPORTS=on` to configure your project, or uncomment the last line (`set_property(TARGET ${PROJECT_NAME} PROPERTY ENABLE_EXPORTS ON)`) in your project's CMakeLists.txt, and then rebuild the project** -# Next: [Session](/drogon-docs/#/ENG/ENG-07-Session) +# Next: [Session](/ENG/ENG-07-Session) diff --git a/ENG/ENG-07-Session.md b/ENG/ENG-07-Session.md index c4f8a5d..2ee6b4d 100644 --- a/ENG/ENG-07-Session.md +++ b/ENG/ENG-07-Session.md @@ -1,5 +1,7 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-07-会话) +##### Other languages: [简体中文](/CHN/CHN-07-会话) +# Session + `Session` is an important concept of the web application. It is used to save the state of the client on the server. Generally, it cooperates with the browser's `cookie`, and drogon provides support for the session. Drogon **close** the session selection by default, you can also close or open it through the following interface: ```c++ @@ -96,4 +98,4 @@ drogon::HttpAppFramework::instance().enableSession(1200); Recompile the entire project with CMake, run the target program webapp, and you can see the effect through the browser. -# Next: [Database](/drogon-docs/#/ENG/ENG-08-0-Database-General) +# Next: [Database](/ENG/ENG-08-0-Database-General) diff --git a/ENG/ENG-08-0-Database-General.md b/ENG/ENG-08-0-Database-General.md index 450880f..5087a48 100644 --- a/ENG/ENG-08-0-Database-General.md +++ b/ENG/ENG-08-0-Database-General.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-08-0-数据库-概述) +##### Other languages: [简体中文](/CHN/CHN-08-2-数据库-事务) + +# Database - General ### General @@ -24,4 +26,4 @@ The transaction object can be generated by `DbClient` to support transaction ope Drogon also provides support for **ORM**. Users can use the drogon_ctl command to read the tables in the database and generate the corresponding model source code. Then, execute the database operations of these models through the `Mapper` class template. Mapper provides simple and convenient interfaces for standard database operations, allowing users to make the additions, deletions, and changes to the table without writing sql statements. For **ORM**, please refer to [ORM](/ENG//ENG/ENG-08-3-Database-ORM) -# Next: [DbClient](/drogon-docs/#/ENG/ENG-08-1-Database-DbClient) +# Next: [DbClient](/ENG/ENG-08-1-Database-DbClient) diff --git a/ENG/ENG-08-1-Database-DbClient.md b/ENG/ENG-08-1-Database-DbClient.md index 37c63a0..d5e47db 100644 --- a/ENG/ENG-08-1-Database-DbClient.md +++ b/ENG/ENG-08-1-Database-DbClient.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-08-1-数据库-DbClient) +##### Other languages: [简体中文](/CHN/CHN-08-1-数据库-DbClient) + +# Database - DbClient ### DbClient Object Construction @@ -253,4 +255,4 @@ Each DbClient object has one or multiple its own EventLoop threads controlling t Blocking interfaces of DbClient only block the caller thread, as long as the caller thread is not the EventLoop thread, it will not affect the normal operation of the EventLoop thread. When the callback function is called, the program inside the callback is run on the EventLoop thread. Therefore, do not perform any blocking operations within the callback, otherwise it will affect the concurrency performance of database read and write. Anyone familiar with non-blocking I/O programming should understand this constraint. -# Next: [Transaction](/drogon-docs/#/ENG/ENG-08-2-Database-Transaction) +# Next: [Transaction](/ENG/ENG-08-2-Database-Transaction) diff --git a/ENG/ENG-08-2-Database-Transaction.md b/ENG/ENG-08-2-Database-Transaction.md index 381ca8e..ba8a6e2 100644 --- a/ENG/ENG-08-2-Database-Transaction.md +++ b/ENG/ENG-08-2-Database-Transaction.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-08-2-数据库-事务) +##### Other languages: [简体中文](/CHN/CHN-08-2-数据库-事务) + +# Database - Transactions > **Transactions** are an important feature of relational databases, and Drogon provides transaction support with the `Transaction` class. @@ -83,4 +85,4 @@ For the simplest example, suppose there is a task table from which the user sele In this case, select for update is used to avoid concurrent modifications. The update statement is completed in the result callback of the select statement. The outermost braces are used to limit the scope of the transPtr so that it can be destroyed in time after the execution of sql to end the transaction. -# Next: [ORM](/drogon-docs/#/ENG/ENG-08-3-Database-ORM) +# Next: [ORM](/ENG/ENG-08-3-Database-ORM) diff --git a/ENG/ENG-08-3-Database-ORM.md b/ENG/ENG-08-3-Database-ORM.md index 6f34fb4..7732df2 100644 --- a/ENG/ENG-08-3-Database-ORM.md +++ b/ENG/ENG-08-3-Database-ORM.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-08-3-数据库-ORM) +##### Other languages: [简体中文](/CHN/CHN-08-3-数据库-ORM) + +# Database - ORM ### Model @@ -286,4 +288,4 @@ drogon_ctl can also generate restful-style controllers for each model (or table) It should be noted that the controller of each table is designed to be composed of a base class and a subclass. Among them, the base class and the table are closely related, and the subclass is used to implement special business logic or modify the interface format. The advantage of this design is that when the table structure changes, users can update only the base class without overwriting the subclass(by setting the `generate_base_only` option to `true`). -# Next: [FastDbClient](/drogon-docs/#/ENG/ENG-08-4-Database-FastDbClient) +# Next: [FastDbClient](/ENG/ENG-08-4-Database-FastDbClient) diff --git a/ENG/ENG-08-4-Database-FastDbClient.md b/ENG/ENG-08-4-Database-FastDbClient.md index fdb59f2..c8ebba6 100644 --- a/ENG/ENG-08-4-Database-FastDbClient.md +++ b/ENG/ENG-08-4-Database-FastDbClient.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-08-4-数据库-FastDbClient) +##### Other languages: [简体中文](/CHN/CHN-08-4-数据库-FastDbClient) + +# Database - FastDbClient As the name implies, FastDbClient will provide higher performance than the normal DbClient. Unlike DbClient has own event loop, it shares the event loop with network IO threads and the main thread of the web application, which makes the internal implementation of FastDbClient available in a lock-free mode and more efficient. @@ -30,4 +32,4 @@ The use of FastDbClient is almost identical to that of the normal DbClient, exce - Synchronous transaction creation interfaces are likely to block (when all connections are busy), so FastDbClient's synchronous transaction creation interface returns null pointers directly. If you want to use transactions on FastDbClient, please use the asynchronous transaction creation interface. - After using the FastDbClient to create an Orm Mapper object, you should also use only asynchronous non-blocking interfaces of the mapper object. -# Next: [Automatic batch mode](/drogon-docs/#/ENG/ENG-08-5-Database-auto_batch) +# Next: [Automatic batch mode](/ENG/ENG-08-5-Database-auto_batch) diff --git a/ENG/ENG-08-5-Database-auto_batch.md b/ENG/ENG-08-5-Database-auto_batch.md index 6d7ccc9..564f09d 100644 --- a/ENG/ENG-08-5-Database-auto_batch.md +++ b/ENG/ENG-08-5-Database-auto_batch.md @@ -1,4 +1,6 @@ -##### Other languages: [简体中文](/drogon-docs/#/CHN/CHN-08-5-数据库-自动批处理) +##### Other languages: [简体中文](/CHN/CHN-08-5-数据库-自动批处理) + +# Database - Automatic Batch Mode The automatic batch mode is only valid for the client library of postgresql 14+ version, and will be ignored in other cases. Before talking about automatic batch processing, let's understand the pipeline mode first. @@ -33,4 +35,4 @@ Therefore, automatic batch mode is helpful to improve performance, but it is not When using the newPgClient interface to create a client, set the third parameter to true to enable automatic batch mode; When using a configuration file to create a client, set the auto_batch option to true to enable automatic batch mode for the client; -# Next: [Request References](/drogon-docs/#/ENG/ENG-09-0-References-request) +# Next: [Request References](/ENG/ENG-09-0-References-request) diff --git a/ENG/ENG-09-0-References-request.md b/ENG/ENG-09-0-References-request.md index c77cd9c..484765c 100644 --- a/ENG/ENG-09-0-References-request.md +++ b/ENG/ENG-09-0-References-request.md @@ -1,4 +1,6 @@ +##### Other languages: [简体中文](/CHN/CHN-09-插件) +# References Request The HttpRequest type pointer commonly named `req` in the examples in this documentation represents the data contained in a request received or sent by drogon, below are the some methods by which you can interact with this object: @@ -267,4 +269,4 @@ void mycontroller::postfile(const HttpRequestPtr &req, std::function - Document + Drogon Framework - Documentation diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..a4db56b --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "drogon-docs", + "lockfileVersion": 3, + "requires": true, + "packages": {} +}