Skip to content

Commit

Permalink
updated documentation to fix a few mistakes, clear up a few points, a…
Browse files Browse the repository at this point in the history
…nd added compression guide
  • Loading branch information
The-EDev committed Jun 3, 2021
1 parent ca31b85 commit 2dde0ac
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 15 deletions.
47 changes: 33 additions & 14 deletions docs/getting_started/setup.md
Expand Up @@ -3,21 +3,36 @@ This page explains how to set Crow up for use with your project.

##Requirements
- C++ compiler with C++14 support.
- Continuous Testing on g++-9.3 and clang-7.0, AMD64 (x86_64) and Arm64 v8
- Crow's CI uses g++-9.3 and clang-7.0 running on AMD64 (x86_64) and ARM64v8
- boost library (1.70 or later).
- (optional) CMake and Python3 to build tests and/or examples.
- (optional) Linking with jemalloc/tcmalloc is recommended for speed.
- **(optional)** ZLib for HTTP Compression.
- **(optional)** CMake and Python3 to build tests and/or examples.
- **(optional)** Linking with jemalloc/tcmalloc is recommended for speed.
!!!note

While using Boost 1.70 or later is recommended, it may be possible to compile a Crow application with version 1.64

<br><br>

##Installing Requirements
!!! note

The Linux requirements are for developing and compiling a Crow application. Running a built application requires the actual libraries rather than just the development headers.

###Ubuntu
`sudo apt-get install libboost-all-dev`
`sudo apt-get install build-essential libboost-all-dev`

###Non Debian based GNU/Linux
Use your package manager to install the following:
- GCC and G++ (or Clang and Clang++)
- Boost Development headers (sometimes part of the Boost package itself)


###OSX
`brew install boost`

###Windows
Download boost from [here](https://www.boost.org/) and install it
Microsoft Visual Studio 2019 (older versions not tested)

##Downloading
Either run `git clone https://github.com/crowcpp/crow.git` or download `crow_all.h` from the releases section. You can also download a zip of the project on github.
Expand All @@ -29,7 +44,7 @@ Either run `git clone https://github.com/crowcpp/crow.git` or download `crow_all
<br><br>

##Single header file
If you've downloaded `crow_all.h`, you can skip to step 4.
If you've downloaded `crow_all.h`, you can skip to step **4**.

1. Make sure you have python 3 installed.
2. Open a terminal (or `cmd.exe`) instance in `/path/to/crow/scripts`.
Expand All @@ -44,16 +59,18 @@ If you've downloaded `crow_all.h`, you can skip to step 4.
To build a crow Project, do the following:

###GCC (G++)
- Release: `g++ main.cpp -lpthread -lboost_system -lz`.
- Debug: `g++ main.cpp -ggdb -lpthread -lboost_system -lz -D CROW_ENABLE_DEBUG`.
- SSL: `g++ main.cpp -lssl -lcrypto -lpthread -lboost_system -lz -D CROW_ENABLE_SSL`.
- Release: `g++ main.cpp -lpthread -lboost_system`.
- Debug: `g++ main.cpp -ggdb -lpthread -lboost_system -DCROW_ENABLE_DEBUG`.
- SSL: `g++ main.cpp -lssl -lcrypto -lpthread -lboost_system -DCROW_ENABLE_SSL`.

###Clang
- Release: `clang++ main.cpp -lpthread -lboost_system -lz`.
- Debug: `clang++ main.cpp -g -lpthread -lboost_system -lz -DCROW_ENABLE_DEBUG`.
- SSL: `clang++ main.cpp -lssl -lcrypto -lpthread -lboost_system -lz -DCROW_ENABLE_SSL`.
- Release: `clang++ main.cpp -lpthread -lboost_system`.
- Debug: `clang++ main.cpp -g -lpthread -lboost_system -DCROW_ENABLE_DEBUG`.
- SSL: `clang++ main.cpp -lssl -lcrypto -lpthread -lboost_system -DCROW_ENABLE_SSL`.

###Microsoft Visual Studio 2019
The following guide will use `example_with_all.cpp` as the Crow application for demonstration purposes.

###Microsoft Visual Studio 2019 (`example_with_all.cpp`)
1. Generate `crow_all.h` following [Single header file](#single-header-file).
2. `git clone https://github.com/microsoft/vcpkg.git`
3. `.\vcpkg\bootstrap-vcpkg.bat`
Expand Down Expand Up @@ -97,7 +114,9 @@ set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
include_directories("${PROJECT_INCLUDE_DIR}")
```
**Note**: The last 2 lines are unnecessary if you're using `crow_all.h`.
!!!note

The last 2 lines are unnecessary if you're using `crow_all.h`.

##Building Crow tests and examples
Out-of-source build with CMake is recommended.
Expand Down
18 changes: 18 additions & 0 deletions docs/guides/compression.md
@@ -0,0 +1,18 @@
Crow supports Zlib compression using Gzip or Deflate algorithms.

## HTTP Compression
HTTP compression is by default disabled in crow. Do the following to enable it: <br>
1. Add `#!cpp #define CROW_ENABLE_COMPRESSION` to the top of your main source file.
2. Call `#!cpp use_compression(crow::compression::algorithm)` on your crow app.
3. When compiling your application, make sure that ZLIB is included as a dependency. Either through `-lz` argument or `find_package(ZLIB)` in CMake.

!!! note

step 3 is not needed for MSVC since `vcpckg.json` already includes zlib as a dependency by default

For the compression algorim you can use `crow::compression::algorithm::DEFLATE` or `crow::compression::algorithm::GZIP`.<br>
And now your HTTP responses will be compressed.

## Websocket Compression
Crow currently does not support Websocket compression.<br>
Feel free to discuss the subject with us on Github if you're feeling adventurous and want to try to implement it. We appreciate all the help.
4 changes: 3 additions & 1 deletion docs/guides/ssl.md
Expand Up @@ -7,4 +7,6 @@ To enable SSL, first your application needs to define either a `.crt` and `.key`

You can also set your own SSL context (by using `boost::asio::ssl::context ctx`) and then applying it via the `#!cpp app.ssl(ctx)` method.<br><br>

**IMPORTANT NOTICE**: If you plan on using a proxy like Nginx or Apache2, **DO NOT** use SSL in crow, instead define it in your proxy instead and keep the connection between the proxy and Crow non-SSL.
!!! warning

If you plan on using a proxy like Nginx or Apache2, **DO NOT** use SSL in crow, instead define it in your proxy and keep the connection between the proxy and Crow non-SSL.
1 change: 1 addition & 0 deletions mkdocs.yml
Expand Up @@ -41,6 +41,7 @@ nav:
- Middleware: guides/middleware.md
- SSL: guides/ssl.md
- Static Files: guides/static.md
- Compression: guides/compression.md
- Websockets: guides/websockets.md
- Writing Tests: guides/testing.md
- Server setup:
Expand Down

0 comments on commit 2dde0ac

Please sign in to comment.