diff --git a/.drone.yml b/.drone.yml index a649d5057..fa19175ed 100644 --- a/.drone.yml +++ b/.drone.yml @@ -15,7 +15,7 @@ steps: commands: - export DEBIAN_FRONTEND=noninteractive - - export TRAVIS_BRANCH=$DRONE_SOURCE_BRANCH + - export TRAVIS_BRANCH=$DRONE_BRANCH - export TRAVIS_JOB_ID=$DRONE_BUILD_NUMBER - apt-get -y update - apt-get -y install libboost-all-dev doxygen mkdocs graphviz zlib1g-dev gcc clang make cmake python3 python3-pip git diff --git a/LICENSE b/LICENSE index 046b8fc1b..9b0cb0f68 100644 --- a/LICENSE +++ b/LICENSE @@ -27,4 +27,4 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -The Crow logo used is under Copyright (c) 2021, Farook Al-Sammarraie (The-EDev), All rights reserved. +The Crow logo and other graphic material (excluding third party logos) used are under Copyright (c) 2021, Farook Al-Sammarraie (The-EDev), All rights reserved. diff --git a/README.md b/README.md index 9147b14eb..28b1f1e26 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ Coverage Status Documentation Gitter +Open Collective

diff --git a/docs/assets/crowlogo_main_color.svg b/docs/assets/crowlogo_main_color.svg new file mode 100644 index 000000000..5929a8b91 --- /dev/null +++ b/docs/assets/crowlogo_main_color.svg @@ -0,0 +1,90 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/docs/assets/fast_icon.svg b/docs/assets/fast_icon.svg new file mode 100644 index 000000000..3c87ba259 --- /dev/null +++ b/docs/assets/fast_icon.svg @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + diff --git a/docs/assets/header_icon.svg b/docs/assets/header_icon.svg new file mode 100644 index 000000000..f82df10fd --- /dev/null +++ b/docs/assets/header_icon.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + diff --git a/docs/assets/og_img.png b/docs/assets/og_img.png new file mode 100644 index 000000000..36574ddad Binary files /dev/null and b/docs/assets/og_img.png differ diff --git a/docs/assets/pkg_logos/arch.png b/docs/assets/pkg_logos/arch.png new file mode 100644 index 000000000..8fd851d44 Binary files /dev/null and b/docs/assets/pkg_logos/arch.png differ diff --git a/docs/assets/pkg_logos/conan.png b/docs/assets/pkg_logos/conan.png new file mode 100644 index 000000000..b0ec063e1 Binary files /dev/null and b/docs/assets/pkg_logos/conan.png differ diff --git a/docs/assets/pkg_logos/github.png b/docs/assets/pkg_logos/github.png new file mode 100644 index 000000000..402191e09 Binary files /dev/null and b/docs/assets/pkg_logos/github.png differ diff --git a/docs/assets/pkg_logos/ubuntu.png b/docs/assets/pkg_logos/ubuntu.png new file mode 100644 index 000000000..5ef25b7c0 Binary files /dev/null and b/docs/assets/pkg_logos/ubuntu.png differ diff --git a/docs/assets/pkg_logos/vcpkg.png b/docs/assets/pkg_logos/vcpkg.png new file mode 100644 index 000000000..899ab89ff Binary files /dev/null and b/docs/assets/pkg_logos/vcpkg.png differ diff --git a/docs/assets/typesafe_icon.svg b/docs/assets/typesafe_icon.svg new file mode 100644 index 000000000..582213166 --- /dev/null +++ b/docs/assets/typesafe_icon.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + diff --git a/docs/assets/websocket_icon.svg b/docs/assets/websocket_icon.svg new file mode 100644 index 000000000..83d54206a --- /dev/null +++ b/docs/assets/websocket_icon.svg @@ -0,0 +1,48 @@ + + + + + + + + + + diff --git a/docs/guides/compression.md b/docs/guides/compression.md index 89b8e80de..d614a3a9b 100644 --- a/docs/guides/compression.md +++ b/docs/guides/compression.md @@ -1,3 +1,4 @@ +**Introduced in: `v0.3`**

Crow supports Zlib compression using Gzip or Deflate algorithms. ## HTTP Compression diff --git a/docs/guides/multipart.md b/docs/guides/multipart.md index 61cc47183..b67c87975 100644 --- a/docs/guides/multipart.md +++ b/docs/guides/multipart.md @@ -1,3 +1,4 @@ +**Introduced in: `v0.2`**

Multipart is a way of forming HTTP requests or responses to contain multiple distinct parts.
Such an approach allows a request to contain multiple different pieces of data with potentially conflicting data types in a single response payload.
It is typically used either in html forms, or when uploading multiple files.

diff --git a/docs/guides/query-string.md b/docs/guides/query-string.md index 34e29be82..dce718b92 100644 --- a/docs/guides/query-string.md +++ b/docs/guides/query-string.md @@ -5,6 +5,7 @@ Crow supports query strings through `crow::request::url_params`. The object is o ##get(name) Returns the value (as char*) based on the given key (or name). Returns `nullptr` if the key is not found. ##pop(name) +**Introduced in: `v0.3`**

Works the same as `get`, but removes the returned value. !!! note @@ -15,11 +16,13 @@ A url can be `http://example.com?key[]=value1&key[]=value2&key[]=value3`. Using `#!cpp get_list("key", false)` can be used to parse `http://example.com?key=value1&key=value2&key=value3` ##pop_list(name) +**Introduced in: `v0.3`**

Works the same as `get_list` but removes all instances of values having the given key (`use_brackets` is also available here). ##get_dict(name) Returns an `std::unordered_map` from a query string such as `?key[sub_key1]=value1&key[sub_key2]=value2&key[sub_key3]=value3`.
The key in the map is what's in the brackets (`sub_key1` for example), and the value being what's after the `=` sign (`value1`). The name passed to the function is not part of the returned value. ##pop_dict(name) +**Introduced in: `v0.3`**

Works the same as `get_dict` but removing the values from the query string. !!!warning diff --git a/docs/guides/routes.md b/docs/guides/routes.md index 977df25e1..e7fe72435 100644 --- a/docs/guides/routes.md +++ b/docs/guides/routes.md @@ -52,6 +52,7 @@ The main return type is `std::string`. although you could also return a `crow::j For more information on the specific constructors for a `crow::response` go [here](../../reference/structcrow_1_1response.html). ##Returning custom classes +**Introduced in: `v0.3`**

If you have your own class you want to return (without converting it to string and returning that), you can use the `crow::returnable` class.
to use the returnable class, you only need your class to publicly extend `crow::returnable`, add a `dump()` method that returns your class as an `std::string`, and add a constructor that has a `Content-Type` header as a string argument.

@@ -73,4 +74,5 @@ class a : public crow::returnable ``` ##Catchall routes +**Introduced in: `v0.3`**

By default, any request that Crow can't find a route for will return a simple 404 response. You can change that to return a default route using the `CROW_CATCHALL_ROUTE(app)` macro. Defining it is identical to a normal route, even when it comes to the `const crow::request&` and `crow::response&` parameters being optional. diff --git a/docs/guides/static.md b/docs/guides/static.md index 9be03dbbf..7659d2dbf 100644 --- a/docs/guides/static.md +++ b/docs/guides/static.md @@ -1,3 +1,4 @@ +**Introduced in: `v0.2`**

A static file is any file that resides in the server's storage. Crow supports returning Static files as responses in 2 ways. diff --git a/docs/index.md b/docs/index.md index 587f35f7f..a572d90d6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,105 +1,3 @@ -# -

- -

A Fast and Easy to use microframework for the web.

-

-Build Status -Coverage Status -Documentation -Gitter -

- - -## Description - -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. - -### Features - - Easy Routing (similar to flask). - - Type-safe Handlers. - - Blazingly fast (see [this benchmark](https://github.com/ipkn/crow-benchmark) and [this benchmark](https://github.com/guteksan/REST-CPP-benchmark)). - - Built in JSON support. - - [Mustache](http://mustache.github.io/) based templating library (`crow::mustache`). - - Header only library (single header file available). - - Middleware support for extensions. - - HTTP/1.1 and Websocket support. - - Multi-part request and response support. - - Uses modern C++ (11/14) - -### Still in development - - [HTTP/2 support](https://github.com/crowcpp/crow/issues/8) - -## Documentation -Available [here](https://crowcpp.org). - -## Examples - -#### Hello World -```cpp -#define CROW_MAIN -#include "crow.h" - -int main() -{ - crow::SimpleApp app; - - CROW_ROUTE(app, "/")([](){ - return "Hello world"; - }); - - app.port(18080).multithreaded().run(); -} -``` - -#### JSON Response -```cpp -CROW_ROUTE(app, "/json") -([]{ - crow::json::wvalue x; - x["message"] = "Hello, World!"; - return x; -}); -``` - -#### Arguments -```cpp -CROW_ROUTE(app,"/hello/") -([](int count){ - if (count > 100) - return crow::response(400); - std::ostringstream os; - os << count << " bottles of beer!"; - return crow::response(os.str()); -}); -``` -Handler arguments type check at compile time -```cpp -// Compile error with message "Handler type is mismatched with URL paramters" -CROW_ROUTE(app,"/another/") -([](int a, int b){ - return crow::response(500); -}); -``` - -#### Handling JSON Requests -```cpp -CROW_ROUTE(app, "/add_json") -.methods("POST"_method) -([](const crow::request& req){ - auto x = crow::json::load(req.body); - if (!x) - return crow::response(400); - int sum = x["a"].i()+x["b"].i(); - std::ostringstream os; - os << sum; - return crow::response{os.str()}; -}); -``` - -More examples can be found [here](https://github.com/crowcpp/crow/tree/master/examples). - -## Setting Up / Building -Available [here](https://crowcpp.org/getting_started/setup). - -## Disclaimer -CrowCpp/Crow is a project based on ipkn/crow. Neither CrowCpp, it's members, or this project have been associated with, or endorsed or supported by ipkn (Jaeseung Ha) in any way. We do use ipkn/crow's source code under the BSD-3 clause license and sometimes refer to the public comments available on the github repository. But we do not in any way claim to be associated with or in contact with ipkn (Jaeseung Ha) regarding CrowCpp or CrowCpp/Crow +--- +template: home.html +--- diff --git a/docs/overrides/home.html b/docs/overrides/home.html new file mode 100644 index 000000000..e15ac171c --- /dev/null +++ b/docs/overrides/home.html @@ -0,0 +1,300 @@ +{% extends "main.html" %} + + + + +{% block content %} + + + +

A Fast and Easy to use microframework for the web.

+ +
+ +
+
+ +

Blazingly Fast

+
+
+ +

Header Only

+
+
+ +

Typesafe handlers

+
+
+ +

Websocket Support

+
+
+ + +
+ +
+
+

Easy to get started

+
+
+
#define CROW_MAIN
+#include "crow.h"
+
+int main()
+{
+    crow::SimpleApp app;
+
+    CROW_ROUTE(app, "/")([](){
+        return "Hello world";
+    });
+
+    app.port(18080).run();
+}
+
+
+
+ +
+
+
CROW_ROUTE(app, "/json")
+([]{
+    crow::json::wvalue x;
+    x["message"] = "Hello, World!";
+    return x;
+});
+
+
+
+

JSON Support Built-in

+
+ +
+ +
+
+

URL parameter support as well!

+
+
+
CROW_ROUTE(app,"/hello/<int>")
+([](int count){
+    return crow::response(std::to_string(count));
+});
+
+
+
+ +
+ +

Support Crow

+

Crow is provided free of charge courtesy of everyone who is donating their money, time, and expertise to keep it going.

+

Help us make something great!

+ + + Fund Crow + Develop Crow + Chat with us + + +
+

Get Crow

+

Crow is everywhere, you just need to grab it!

+ +
+ + + + + + + + + + + +
+ +
+

Learn Crow

+

The 1000 mile journey begins with a single step. Get started by installing Crow and building you first application. Or go through the guides if you're stuck somewhere.

+ + + Get Started + Guides + API Reference + + + + + +{% endblock %} + +{% block site_nav %}{% endblock %} +{% block footer %} + +
+ + +
+{% endblock %} diff --git a/docs/overrides/main.html b/docs/overrides/main.html new file mode 100644 index 000000000..e3dfe8716 --- /dev/null +++ b/docs/overrides/main.html @@ -0,0 +1,9 @@ +{% extends "base.html" %} + +{% block extrahead %} + + + + + +{% endblock %} diff --git a/docs/overrides/partials/header.html b/docs/overrides/partials/header.html new file mode 100644 index 000000000..38ad4a17a --- /dev/null +++ b/docs/overrides/partials/header.html @@ -0,0 +1,150 @@ + + + +
+ +
diff --git a/docs/stylesheets/colors.css b/docs/stylesheets/colors.css index aa0a82f38..25a055a1c 100644 --- a/docs/stylesheets/colors.css +++ b/docs/stylesheets/colors.css @@ -1,6 +1,31 @@ :root { - --md-primary-fg-color: #161616; - --md-accent-fg-color: #396A97; - --md-typeset-a-color: var(--md-accent-fg-color); + --md-primary-fg-color: #24404f; + --md-accent-fg-color: #122027; + --md-typeset-a-color: var(--md-accent-fg-color) !important; + --md-default-bg-color: #e5f2f8; + --md-code-bg-color: #2e3639 !important; + --md-code-hl-punctuation-color: #fff !important; +} + +.md-typeset code { + background-color: #2e3639; + color: #afafaf; +} + +.linenos { + background-color: #2e3639 !important; + color: #afafaf !important; +} + +.highlight .p { + color: #bbb; +} + +.highlight .o { + color: #afafaf; +} + +.highlight .n { + color: #afafaf; } diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css new file mode 100644 index 000000000..bb9c440a6 --- /dev/null +++ b/docs/stylesheets/extra.css @@ -0,0 +1,8 @@ +.md-header__source { + margin-left: 0px; + width: autho; + min-width: 9.6rem; +} +.code { + border-radius: 5px; +} diff --git a/mkdocs.yml b/mkdocs.yml index adac457e4..968324c90 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -16,6 +16,7 @@ theme: logo: 'assets/favicon.svg' icon: repo: fontawesome/brands/github-square + custom_dir: docs/overrides markdown_extensions: - admonition @@ -61,5 +62,6 @@ extra: extra_css: - 'stylesheets/colors.css' - 'stylesheets/latofonts.css' + - 'stylesheets/extra.css' -copyright: 'Copyright © 2021 CrowCpp' +copyright: 'Copyright © 2020-2021 CrowCpp'