Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix more broken links #76

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHN/CHN-01-概述.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[English](/ENG/ENG-01-Overview) | [简体中文](/CHN/CHN-01-概述)

**Drogon**是一个基于C++17/20的Http应用框架,使用Drogon可以方便的使用C++构建各种类型的Web应用服务端程序。
**Drogon**是一个基于C++20的Http应用框架,使用Drogon可以方便的使用C++构建各种类型的Web应用服务端程序。

Drogon的主要应用平台是Linux,也支持Mac OS、FreeBSD和Windows。

Expand Down Expand Up @@ -29,4 +29,4 @@ Drogon的主要应用平台是Linux,也支持Mac OS、FreeBSD和Windows。
* 支持插件,可通过配置文件在加载期动态拆装;
* 支持内建插入点的AOP

# 02 [安装drogon](/CHN/CHN-02-安装)
# 02 [安装drogon](/CHN/CHN-02-安装)
2 changes: 1 addition & 1 deletion CHN/CHN-02-安装.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* libuuid,生成uuid的c库;
* zlib,用于支持压缩传输;
* 可选
* boost,版本**不低于1.61**,只在C++编译器不支持c++17或STL库不完整支持`std::filesystem`时才需要安装;
* boost,版本**不低于1.61**,只在C++编译器不支持c++20或STL库不完整支持`std::filesystem`时才需要安装;
* OpenSSL,安装后drogon将支持HTTPS,否则drogon只支持HTTP;
* c-ares, 安装后drogon对DNS的支持会具有更好的性能;
* libbrotli,安装后drogon的HTTP响应会支持brotli压缩;
Expand Down
6 changes: 3 additions & 3 deletions ENG/ENG-01-Overview.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##### Other languages: [简体中文](/CHN//CHN//CHN/CHN-01-概述)
##### Other languages: [简体中文](/CHN/CHN-01-概述)

**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++.
**Drogon** is a C++20-based HTTP application framework. Drogon can be used to easily build various types of web application server programs using C++.

**Drogon** is the name of a dragon in the American TV series "Game of Thrones" that I really like.

Expand Down Expand Up @@ -31,4 +31,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](/ENG//ENG//ENG/ENG-02-Installation)
# Next: [Install drogon](/ENG/ENG-02-Installation)
7 changes: 4 additions & 3 deletions ENG/ENG-02-Installation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##### Other languages: [简体中文](/CHN//CHN//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;

Expand Down Expand Up @@ -291,7 +291,7 @@ Assuming that the above environment and library dependencies are all ready, the
mkdir build
cd build
conan profile detect --force
conan install .. -s compiler="msvc" -s compiler.version=193 -s compiler.cppstd=17 -s build_type=Debug --output-folder . --build=missing
conan install .. -s compiler="msvc" -s compiler.version=193 -s compiler.cppstd=20 -s build_type=Debug --output-folder . --build=missing
```

> Modify `conanfile.txt` to change the version of dependencies.
Expand Down Expand Up @@ -481,4 +481,5 @@ Assuming that the above environment and library dependencies are all ready, the
target_link_libraries(${PROJECT_NAME} PRIVATE drogon)
```

# Next: [Quick Start](/ENG//ENG//ENG/ENG-03-Quick-Start)

# Next: [Quick Start](/ENG/ENG-03-Quick-Start)
21 changes: 15 additions & 6 deletions ENG/ENG-03-Quick-Start.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##### Other languages: [简体中文](/CHN//CHN//CHN/CHN-03-快速开始)
##### Other languages: [简体中文](/CHN/CHN-03-快速开始)

## Static Site

Expand All @@ -22,7 +22,11 @@ There are several useful folders in the project directory already:
└── views The folder where view csp files are stored
```

Users can put various files (such as controllers, filters, views, etc.) into the corresponding folders. For more convenience and less error, we strongly recommend that users create their own web application projects using the `drogon_ctl` command. See [drogon_ctl](/ENG//ENG/ENG-11-drogon_ctl-Command) for more details.

Users can put various files (such as controllers, filters, views, etc.) into the corresponding folders. For more convenience and less error, we strongly recommend that users create their own web application projects using the `drogon_ctl` command. See [drogon_ctl](/ENG/ENG-11-drogon_ctl-Command) for more details.
=======
Users can put various files (such as controllers, filters, views, etc.) into the corresponding folders. For more convenience and less error, we strongly recommend that users create their own web application projects using the `drogon_ctl` command. See [drogon_ctl](/ENG/ENG-11-drogon_ctl-Command) for more details.


Let's look at the main.cc file:

Expand Down Expand Up @@ -55,12 +59,16 @@ Now, we simply add one static file index.html to the Http root path:
echo '<h1>Hello Drogon!</h1>' >>index.html
```

The default root path is `"./"`, but could also be modified by config.json. See [Configuration File](/ENG//ENG/ENG-10-Configuration-File) for more details. Then you can visit this page by URL `"http://localhost"` or`"http://localhost/index.html"` (or the IP of the server where your wepapp is running).

![Hello Drogon!](images/hellodrogon.png)
The default root path is `"./"`, but could also be modified by config.json. See [Configuration File](/ENG/ENG-10-Configuration-File) for more details. Then you can visit this page by URL `"http://localhost"` or`"http://localhost/index.html"` (or the IP of the server where your wepapp is running).
=======
The default root path is `"./"`, but could also be modified by config.json. See [Configuration File](/ENG/ENG-10-Configuration-File) for more details. Then you can visit this page by URL `"http://localhost"` or`"http://localhost/index.html"` (or the IP of the server where your wepapp is running).


![Hello Drogon!](/images/hellodrogon.png)

If the server cannot find the the page you have requested, it returns a 404 page:
![404 page](images/notfound.png)
![404 page](/images/notfound.png)

> **Note: Make sure your server firewall has allowed the 80 port. Otherwise, you won't see these pages.(Another way is to change your port from 80 to 1024(or above) in case you get the error message below):**

Expand Down Expand Up @@ -194,4 +202,5 @@ 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](/ENG//ENG/ENG-04-0-Controller-Introduction)

# Next: [drogon_ctl Command](/ENG/ENG-04-0-Controller-Introduction)
7 changes: 4 additions & 3 deletions ENG/ENG-04-0-Controller-Introduction.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##### Other languages: [简体中文](/CHN//CHN/CHN-04-控制器-简介)
##### Other languages: [简体中文](/CHN/CHN-04-控制器-简介)

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:
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-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:

```c++
Void handlerName(const HttpRequestPtr &req,
Expand Down Expand Up @@ -33,4 +33,5 @@ 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](/ENG//ENG/ENG-04-1-Controller-HttpSimpleController)

# Next: [HttpSimpleController](/ENG/ENG-04-1-Controller-HttpSimpleController)
12 changes: 9 additions & 3 deletions ENG/ENG-04-1-Controller-HttpSimpleController.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
##### Other languages: [简体中文](/CHN//CHN/CHN-04-1-控制器-HttpSimpleController)
##### Other languages: [简体中文](/CHN/CHN-04-1-控制器-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:

Expand Down Expand Up @@ -47,7 +48,11 @@ Each HttpSimpleController class can only define one Http request handler, and it

The route (or called mapping) from the URL path to the handler is done by a macro. You could add multipath mappings with the `PATH_ADD` macro. All `PATH_ADD` statements should be set between the `PATH_LIST_BEGIN` and `PATH_LIST_END` macro statements.

The first parameter is the path to be mapped, and parameters beyond the path are constraints on this path. Currently, two types of constraints are supported. One is the `HttpMethod` enum Type, which means the Http method allowed. The other type is the name of the `HttpFilter` class. One can configure any number of these two types of constraints, and there are no order requirements for them. For Filter, please refer to [Middleware and Filter](/ENG//ENG/ENG-05-Middleware-and-Filter).

The first parameter is the path to be mapped, and parameters beyond the path are constraints on this path. Currently, two types of constraints are supported. One is the `HttpMethod` enum Type, which means the Http method allowed. The other type is the name of the `HttpFilter` class. One can configure any number of these two types of constraints, and there are no order requirements for them. For Filter, please refer to [Middleware and Filter](/ENG/ENG-05-Middleware-and-Filter).
=======
The first parameter is the path to be mapped, and parameters beyond the path are constraints on this path. Currently, two types of constraints are supported. One is the `HttpMethod` enum Type, which means the Http method allowed. The other type is the name of the `HttpFilter` class. One can configure any number of these two types of constraints, and there are no order requirements for them. For Filter, please refer to [Middleware and Filter](/ENG/ENG-05-Middleware-and-Filter).


Users can register the same Simple Controller to multiple paths, or register multiple Simple Controllers on the same path (using different HTTP methods).

Expand All @@ -64,4 +69,5 @@ 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](/ENG//ENG/ENG-04-2-Controller-HttpController)

# Next: [HttpController](/ENG/ENG-04-2-Controller-HttpController)
6 changes: 4 additions & 2 deletions ENG/ENG-04-2-Controller-HttpController.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
##### Other languages: [简体中文](/CHN//CHN/CHN-04-2-控制器-HttpController)
##### Other languages: [简体中文](/CHN/CHN-04-2-控制器-HttpController)


### Generation

Expand Down Expand Up @@ -279,4 +280,5 @@ 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](/ENG//ENG/ENG-04-3-Controller-WebSocketController)

# Next: [WebSocketController](/ENG/ENG-04-3-Controller-WebSocketController)
12 changes: 9 additions & 3 deletions ENG/ENG-04-3-Controller-WebSocketController.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
##### Other languages: [简体中文](/CHN//CHN/CHN-04-3-控制器-WebSocketController)
##### Other languages: [简体中文](/CHN/CHN-04-3-控制器-WebSocketController)


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.

Expand Down Expand Up @@ -100,7 +101,11 @@ void EchoWebsock::handleConnectionClosed(const WebSocketConnectionPtr &wsConnPtr
}
```

First, in this example, the controller is registered to the `/echo` path via the `WS_PATH_ADD` macro. The usage of the `WS_PATH_ADD` macro is similar to the macros of other controllers introduced earlier. One can also register the path with several [Filters](/ENG//ENG/ENG-05-Middleware-and-Filter). Since websocket is handled separately in the framework, it can be repeated with the paths of the first two controllers(`HttpSimpleController` and `HttpApiController`) without affecting each other.

First, in this example, the controller is registered to the `/echo` path via the `WS_PATH_ADD` macro. The usage of the `WS_PATH_ADD` macro is similar to the macros of other controllers introduced earlier. One can also register the path with several [Filters](/ENG/ENG-05-Middleware-and-Filter). Since websocket is handled separately in the framework, it can be repeated with the paths of the first two controllers(`HttpSimpleController` and `HttpApiController`) without affecting each other.
=======
First, in this example, the controller is registered to the `/echo` path via the `WS_PATH_ADD` macro. The usage of the `WS_PATH_ADD` macro is similar to the macros of other controllers introduced earlier. One can also register the path with several [Filters](/ENG/ENG-05-Middleware-and-Filter). Since websocket is handled separately in the framework, it can be repeated with the paths of the first two controllers(`HttpSimpleController` and `HttpApiController`) without affecting each other.


Secondly, in the implementation of the three virtual functions in this example, only the handleNewMessage has the substance, but simply sends the received message back to the client through the send interface.Compile this controller into the framework, you can see the effect, please test it yourself.

Expand Down Expand Up @@ -150,4 +155,5 @@ void EchoWebsock::handleConnectionClosed(const WebSocketConnectionPtr &wsConnPtr
any *getMutableContext();
```

# Next: [Middleware and Filter](/ENG//ENG/ENG-05-Middleware-and-Filter)

# Next: [Middleware and Filter](/ENG/ENG-05-Middleware-and-Filter)
13 changes: 9 additions & 4 deletions ENG/ENG-05-Middleware-and-Filter.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
##### Other languages: [简体中文](/CHN//CHN/CHN-05-中间件和过滤器)
##### Other languages: [简体中文](/CHN/CHN-05-中间件和过滤器)

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.
In HttpController's [example](/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.

Drogon's middleware uses the onion model. After the framework completes URL path matching, it sequentially invokes the middleware registered for that path. Within each middleware, users can choose to intercept or pass through the request and add pre-processing and post-processing logic.

Expand Down Expand Up @@ -71,7 +71,11 @@ Drogon contains the following common filters:
};
```

You could create filter by the `drogon_ctl` command, see [drogon_ctl](/ENG//ENG/ENG-11-drogon_ctl-command#Filter-creation).

You could create filter by the `drogon_ctl` command, see [drogon_ctl](/ENG/ENG-11-drogon_ctl-command#Filter-creation).
=======
You could create filter by the `drogon_ctl` command, see [drogon_ctl](/ENG/ENG-11-drogon_ctl-command#Filter-creation).


You need to override the doFilter virtual function of the parent class to implement the filter logic;

Expand Down Expand Up @@ -100,4 +104,5 @@ 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](/ENG//ENG/ENG-06-View)

# Next: [View](/ENG/ENG-06-View)
6 changes: 4 additions & 2 deletions ENG/ENG-06-View.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
##### Other languages: [简体中文](/CHN//CHN/CHN-06-视图)
##### Other languages: [简体中文](/CHN/CHN-06-视图)


### Views Introduction

Expand Down Expand Up @@ -151,4 +152,5 @@ 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](/ENG//ENG/ENG-07-Session)

# Next: [Session](/ENG/ENG-07-Session)
5 changes: 3 additions & 2 deletions ENG/ENG-07-Session.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##### Other languages: [简体中文](/CHN//CHN/CHN-07-会话)
##### Other languages: [简体中文](/CHN/CHN-07-会话)

`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:

Expand Down Expand Up @@ -96,4 +96,5 @@ 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](/ENG//ENG/ENG-08-0-Database-General)

# Next: [Database](/ENG/ENG-08-0-Database-General)
Loading