Merge branch 'master' into ws_close

This commit is contained in:
Farook Al-Sammarraie 2021-11-09 01:05:06 +03:00 committed by GitHub
commit f3c9306a95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 92 additions and 80 deletions

View File

@ -20,7 +20,6 @@ steps:
- export COVERALLS_PULL_REQUEST=$DRONE_PULL_REQUEST - export COVERALLS_PULL_REQUEST=$DRONE_PULL_REQUEST
- apt-get -y update - apt-get -y update
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git openssl libssl-dev - apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git openssl libssl-dev
- pip3 install mkdocs-material mkdocs-redirects pyyaml --no-input
- git clone https://github.com/CrowCpp/cpp-coveralls.git - git clone https://github.com/CrowCpp/cpp-coveralls.git
- cd cpp-coveralls - cd cpp-coveralls
- pip3 install . --no-input - pip3 install . --no-input
@ -114,7 +113,7 @@ steps:
- export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER - export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER
- apt-get -y update - apt-get -y update
- apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git openssl libssl-dev - apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git openssl libssl-dev
- pip3 install mkdocs-material mkdocs-redirects pyyaml --no-input - pip3 install mkdocs-material mkdocs-redirects pyyaml mkdocs-meta-descriptions-plugin --no-input
- git clone https://github.com/CrowCpp/cpp-coveralls.git - git clone https://github.com/CrowCpp/cpp-coveralls.git
- cd cpp-coveralls - cd cpp-coveralls
- pip3 install . --no-input - pip3 install . --no-input

View File

@ -1,7 +1,7 @@
Here's how you can install Crow on your favorite GNU/Linux distro. Here's how you can install Crow on your favorite GNU/Linux distro.
# Getting Crow ## Getting Crow
## Requirements ### Requirements
- C++ compiler with at least C++11 support. - C++ compiler with at least C++11 support.
- boost library & development headers (1.64 or later). - boost library & development headers (1.64 or later).
- **(optional)** ZLib for HTTP Compression. - **(optional)** ZLib for HTTP Compression.
@ -14,7 +14,7 @@ Here's how you can install Crow on your favorite GNU/Linux distro.
<br><br> <br><br>
## Using a package Manager ### Using a package Manager
You can install Crow on GNU/Linux as a pre-made package You can install Crow on GNU/Linux as a pre-made package
=== "Debian/Ubuntu" === "Debian/Ubuntu"
@ -26,12 +26,12 @@ You can install Crow on GNU/Linux as a pre-made package
<br><br> <br><br>
## Release package ### Release package
Crow provides an archive containing the framework and CMake files, just copy the `include` folder to `/usr/local/include` and `lib` folder to `/usr/local/lib`.<br><br> Crow provides an archive containing the framework and CMake files, just copy the `include` folder to `/usr/local/include` and `lib` folder to `/usr/local/lib`.<br><br>
You can also download the `crow_all.h` file and simply include that into your project. You can also download the `crow_all.h` file and simply include that into your project.
<br><br> <br><br>
## Installing from source ### Installing from source
### Using CMake #### Using CMake
1. Download Crow's source code (Either through github's UI or by using<br> `git clone https://github.com/CrowCpp/Crow.git`). 1. Download Crow's source code (Either through github's UI or by using<br> `git clone https://github.com/CrowCpp/Crow.git`).
2. Run `mkdir build` inside of crow's source directory. 2. Run `mkdir build` inside of crow's source directory.
3. Navigate to the new "build" directory and run the following:<br> 3. Navigate to the new "build" directory and run the following:<br>
@ -41,9 +41,9 @@ You can also download the `crow_all.h` file and simply include that into your pr
You can ignore `-DCROW_BUILD_EXAMPLES=OFF -DCROW_BUILD_TESTS=OFF` if you want to build the Examples and Unit Tests. You can ignore `-DCROW_BUILD_EXAMPLES=OFF -DCROW_BUILD_TESTS=OFF` if you want to build the Examples and Unit Tests.
<br> <br>
### Manually #### Manually
Crow can be installed manually on your Linux computer. Crow can be installed manually on your Linux computer.
#### Multiple header files ##### Multiple header files
=== "Project Only" === "Project Only"
Copy Crow's `include` directory to your project's `include` directory. Copy Crow's `include` directory to your project's `include` directory.
@ -52,7 +52,7 @@ Crow can be installed manually on your Linux computer.
Copy Crow's `include` directory to the `/usr/local/include` directory. Copy Crow's `include` directory to the `/usr/local/include` directory.
#### Single header (crow_all.h) ##### Single header (crow_all.h)
!!!warning !!!warning
`crow_all.h` is recommended only for small, possibly single source file projects, and ideally should not be installed on your system. `crow_all.h` is recommended only for small, possibly single source file projects, and ideally should not be installed on your system.
@ -60,15 +60,15 @@ navigate to the `scripts` directory and run `./merge_all.py ../include crow_all.
!!!note !!!note
You can also include or exclude middlewares from your `crow_all.h` by using `-i` or `-e` followed by the middleware header file names separated by a comma (e.g. `merge_all.py ../include crow_all.h -e cookie_parser` to exclude the cookie parser middleware). You can also include or exclude middlewares from your `crow_all.h` by using `-i` or `-e` followed by the middleware header file names separated by a comma (e.g. `merge_all.py ../include crow_all.h -e cookie_parser` to exclude the cookie parser middleware).
# Compiling your project ## Compiling your project
## Using CMake ### Using CMake
In order to get your CMake project to work with Crow, all you need are the following lines in your CMakeLists.txt: In order to get your CMake project to work with Crow, all you need are the following lines in your CMakeLists.txt:
``` ```
find_package(Crow) find_package(Crow)
target_link_libraries(your_project PUBLIC Crow::Crow) target_link_libraries(your_project PUBLIC Crow::Crow)
``` ```
From there CMake should handle compiling and linking your project. From there CMake should handle compiling and linking your project.
## Directly using a compiler ### Directly using a compiler
All you need to do is run the following command: All you need to do is run the following command:
``` ```
g++ main.cpp -lpthread g++ main.cpp -lpthread

View File

@ -1,17 +1,17 @@
Here's how you can install Crow on your Mac. Here's how you can install Crow on your Mac.
# Getting Crow ## Getting Crow
## From a [release](https://github.com/CrowCpp/Crow/releases) ### From a [release](https://github.com/CrowCpp/Crow/releases)
### Archive #### Archive
Crow provides an archive containing the framework and CMake files, You will only need the `include` folder inside that archive. Crow provides an archive containing the framework and CMake files, You will only need the `include` folder inside that archive.
### Single header file #### Single header file
You can also download the `crow_all.h` file which replaces the `include` folder. You can also download the `crow_all.h` file which replaces the `include` folder.
## From Source ### From Source
To get Crow from source, you only need to download the repository (as a `.zip` or through `git clone https://github.com/CrowCpp/Crow.git`). To get Crow from source, you only need to download the repository (as a `.zip` or through `git clone https://github.com/CrowCpp/Crow.git`).
### include folder #### include folder
Once you've downloaded Crow's source code, you only need to take the `include` folder. Once you've downloaded Crow's source code, you only need to take the `include` folder.
### Single header file #### Single header file
You can generate your own single header file by using navigating to the `scripts` folder with your terminal and running the following command: You can generate your own single header file by navigating to the `scripts` folder with your terminal and running the following command:
``` ```
python3 merge_all.py ../include crow_all.h python3 merge_all.py ../include crow_all.h
``` ```
@ -21,8 +21,8 @@ This will generate a `crow_all.h` file which you can use in the following steps
`crow_all.h` is recommended only for small, possibly single source file projects. For larger projects, it is advised to use the multi-header version. `crow_all.h` is recommended only for small, possibly single source file projects. For larger projects, it is advised to use the multi-header version.
# Setting up your Crow project ## Setting up your Crow project
## Using XCode ### Using XCode
1. Download and install [Homebrew](https://brew.sh). 1. Download and install [Homebrew](https://brew.sh).
2. Run `brew install boost` in your terminal. 2. Run `brew install boost` in your terminal.
3. Create a new XCode project (macOS -> Command Line Tool). 3. Create a new XCode project (macOS -> Command Line Tool).
@ -35,7 +35,7 @@ This will generate a `crow_all.h` file which you can use in the following steps
=== "Single Header" === "Single Header"
1. Place `crow_all.h` inside your project folder and add it to the project in XCode (you need to use the File -> ) 1. Place `crow_all.h` inside your project folder and add it to the project in XCode (you need to use File -> Add files to "project_name")
2. Add header search paths for boost's folder (`/usr/local/include`, and `/usr/local/Cellar/boost/include`) 2. Add header search paths for boost's folder (`/usr/local/include`, and `/usr/local/Cellar/boost/include`)
3. Add linker flags (`-lpthread` and `-lboost_system` if you're running an old version of boost) 3. Add linker flags (`-lpthread` and `-lboost_system` if you're running an old version of boost)
@ -43,7 +43,7 @@ This will generate a `crow_all.h` file which you can use in the following steps
6. Press `▶` to compile and run your Crow application. 6. Press `▶` to compile and run your Crow application.
# Building Crow's tests/examples ## Building Crow's tests/examples
1. Download and install [Homebrew](https://brew.sh). 1. Download and install [Homebrew](https://brew.sh).
2. Run `brew install cmake boost` in your terminal. 2. Run `brew install cmake boost` in your terminal.
3. Get Crow's source code (the entire source code). 3. Get Crow's source code (the entire source code).

View File

@ -1,11 +1,11 @@
Here's how you can install Crow on your Windows machine. Here's how you can install Crow on your Windows machine.
# Getting and Compiling Crow ## Getting and Compiling Crow
## Using A package manager ### Using A package manager
### VCPKG #### VCPKG
Crow can be simply installed through VCPKG using the command `vcpkg install crow` Crow can be simply installed through VCPKG using the command `vcpkg install crow`
## Manually (source or release) ### Manually (source or release)
### Microsoft Visual Studio 2019 and VCPKG #### Microsoft Visual Studio 2019 and VCPKG
The following guide will use `example_with_all.cpp` as the Crow application for demonstration purposes. VCPKG will be used only to install Crow's dependencies. The following guide will use `example_with_all.cpp` as the Crow application for demonstration purposes. VCPKG will be used only to install Crow's dependencies.
1. Generate `crow_all.h` by navigating to the `scripts` folder and running `python3 merge_all.py ..\include crow_all.h`. 1. Generate `crow_all.h` by navigating to the `scripts` folder and running `python3 merge_all.py ..\include crow_all.h`.

View File

@ -27,7 +27,7 @@ CROW_ROUTE(app, "/")([](){
``` ```
For more details on routes, please go [here](../../guides/routes). For more details on routes, please go [here](../../guides/routes).
#4. Running the app ## 4. Running the app
Once you're happy with how you defined all your routes, you're going to want to instruct Crow to run your app. This is done using the `run()` method. Once you're happy with how you defined all your routes, you're going to want to instruct Crow to run your app. This is done using the `run()` method.
``` cpp ``` cpp
app.port(18080).multithreaded().run(); app.port(18080).multithreaded().run();

View File

@ -22,7 +22,7 @@ To do that, you need to convert it to a `wvalue`, which can be done by simply wr
For more info on read values go [here](/reference/classcrow_1_1json_1_1rvalue.html).<br><br> For more info on read values go [here](/reference/classcrow_1_1json_1_1rvalue.html).<br><br>
#wvalue ## wvalue
JSON write value, used for creating, editing and converting JSON to a string.<br><br> JSON write value, used for creating, editing and converting JSON to a string.<br><br>
!!!note !!!note

View File

@ -1,5 +1,6 @@
**Introduced in: `v0.2`**<br><br> **Introduced in: `v0.2`**<br><br>
Multipart is a way of forming HTTP requests or responses to contain multiple distinct parts.<br> Multipart is a way of forming HTTP requests or responses to contain multiple distinct parts.<br>
Such an approach allows a request to contain multiple different pieces of data with potentially conflicting data types in a single response payload.<br> Such an approach allows a request to contain multiple different pieces of data with potentially conflicting data types in a single response payload.<br>
It is typically used either in html forms, or when uploading multiple files.<br><br> It is typically used either in html forms, or when uploading multiple files.<br><br>

View File

@ -2,13 +2,13 @@ Websockets are a way of connecting a client and a server without the request res
To create a websocket in Crow, you need a websocket route.<br> To create a websocket in Crow, you need a websocket route.<br>
A websocket route differs from a normal route quite a bit. While it uses the same `CROW_ROUTE(app, "/url")` macro, that's about where the similarities end.<br> A websocket route differs from a normal route quite a bit. While it uses the same `CROW_ROUTE(app, "/url")` macro, that's about where the similarities end.<br>
A websocket route follows the macro with `.websocket()` which is then followed by a series of methods (with handlers inside) for each event. These are: A websocket route follows the macro with `.websocket()` which is then followed by a series of methods (with handlers inside) for each event. These are (sorted by order of execution):
- `#!cpp onopen([&](crow::websocket::connection& conn){handler code goes here})`
- `#!cpp onaccept([&](const crow::request&){handler code goes here})` (This handler has to return bool) - `#!cpp onaccept([&](const crow::request&){handler code goes here})` (This handler has to return bool)
- `#!cpp onopen([&](crow::websocket::connection& conn){handler code goes here})`
- `#!cpp onmessage([&](crow::websocket::connection& conn, const std::string message, bool is_binary){handler code goes here})` - `#!cpp onmessage([&](crow::websocket::connection& conn, const std::string message, bool is_binary){handler code goes here})`
- `#!cpp onclose([&](crow::websocket::connection& conn, const std::string reason){handler code goes here})` - `#!cpp onerror([&](crow::websocket::connection& conn){handler code goes here})`
- `#!cpp onerror([&](crow::websocket::connection& conn){handler code goes here})`<br><br> - `#!cpp onclose([&](crow::websocket::connection& conn, const std::string reason){handler code goes here})`<br><br>
These event methods and their handlers can be chained. The full Route should look similar to this: These event methods and their handlers can be chained. The full Route should look similar to this:
```cpp ```cpp

View File

@ -2,6 +2,17 @@
<!-- Render hero under tabs --> <!-- Render hero under tabs -->
{% block extrahead %}
<meta property="og:title" content="CrowCpp"/>
<meta property="og:type" content="website" />
<meta property="og:description" content="A Fast and Easy to use microframework for the web."/>
<meta name="description" content="Crow is a C++ microframework for running web services. It uses routing similar to Python's Flask which makes it easy to use. It is also extremely fast, beating multiple existing C++ frameworks as well as non C++ frameworks.">
<meta property="og:image" content="/assets/og_img.png" />
<meta property="og:url" content="https://crowcpp.org">
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:image" content="/assets/og_img.png">
{% endblock %}
<!-- Content --> <!-- Content -->
{% block content %} {% block content %}
<style> <style>

View File

@ -74,6 +74,7 @@ plugins:
- redirects: - redirects:
redirect_maps: redirect_maps:
'getting_started/setup/': 'getting_started/setup/linux.md' 'getting_started/setup/': 'getting_started/setup/linux.md'
- meta-descriptions
extra_css: extra_css:
- 'stylesheets/colors.css' - 'stylesheets/colors.css'