diff --git a/README.md b/README.md index faf7bc234..dea5f61e6 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ Available [here](https://crowcpp.org). #### Hello World ```cpp -#define CROW_MAIN #include "crow.h" int main() diff --git a/docs/getting_started/your_first_application.md b/docs/getting_started/your_first_application.md index 1eee3f28a..9403c982a 100644 --- a/docs/getting_started/your_first_application.md +++ b/docs/getting_started/your_first_application.md @@ -1,11 +1,7 @@ This page shows how you can get started with a simple hello world application. ## 1. Include -Starting with an empty `main.cpp` file, first add `#!cpp #define CROW_MAIN` then `#!cpp #include "crow.h"` or `#!cpp #include "crow_all.h"` if you're using the single header file. - -!!! note - - If you're using multiple C++ source files make sure to have `CROW_MAIN` defined only in your main source file. +Starting with an empty `main.cpp` file, first add `#!cpp #include "crow.h"` or `#!cpp #include "crow_all.h"` if you're using the single header file. ## 2. App declaration Next Create a `main()` and declare a `#!cpp crow::SimpleApp` inside, your code should look like this @@ -39,7 +35,6 @@ Please note that the `port()` and `multithreaded()` methods aren't needed, Thoug Once you've followed all the steps above, your code should look similar to this ``` cpp linenums="1" -#define CROW_MAIN //let the compiler know this is your main cpp file #include "crow.h" //#include "crow_all.h" diff --git a/docs/overrides/home.html b/docs/overrides/home.html index 4bfd1f21a..34afe8ab7 100644 --- a/docs/overrides/home.html +++ b/docs/overrides/home.html @@ -169,7 +169,7 @@
#define CROW_MAIN
+
#include "crow.h"
int main()
diff --git a/examples/example.cpp b/examples/example.cpp
index d7085f39e..3218edca1 100644
--- a/examples/example.cpp
+++ b/examples/example.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include "crow.h"
#include
diff --git a/examples/example_blueprint.cpp b/examples/example_blueprint.cpp
index a7f45b6b7..d8ff85033 100644
--- a/examples/example_blueprint.cpp
+++ b/examples/example_blueprint.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include "crow.h"
int main()
diff --git a/examples/example_catchall.cpp b/examples/example_catchall.cpp
index 522812a54..036658b29 100644
--- a/examples/example_catchall.cpp
+++ b/examples/example_catchall.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include
diff --git a/examples/example_chat.cpp b/examples/example_chat.cpp
index d0fa176a6..7b9ec90cb 100644
--- a/examples/example_chat.cpp
+++ b/examples/example_chat.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include "crow.h"
#include
#include
diff --git a/examples/example_compression.cpp b/examples/example_compression.cpp
index bb617a3b5..55e014a13 100644
--- a/examples/example_compression.cpp
+++ b/examples/example_compression.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include "crow.h"
#include "crow/compression.h"
diff --git a/examples/example_json_map.cpp b/examples/example_json_map.cpp
index 03b3d9238..bff2f4bb8 100644
--- a/examples/example_json_map.cpp
+++ b/examples/example_json_map.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#define CROW_JSON_USE_MAP
#include "crow.h"
diff --git a/examples/example_static_file.cpp b/examples/example_static_file.cpp
index 908f9e27f..c909d3e46 100644
--- a/examples/example_static_file.cpp
+++ b/examples/example_static_file.cpp
@@ -1,7 +1,6 @@
//#define CROW_STATIC_DRIECTORY "alternative_directory/"
//#define CROW_STATIC_ENDPOINT "/alternative_endpoint/"
//#define CROW_DISABLE_STATIC_DIR
-#define CROW_MAIN
#include "crow.h"
int main()
@@ -18,10 +17,10 @@ CROW_ROUTE(app, "/")
res.end();
});
-
+
app.port(18080).run();
-
-
+
+
return 0;
}
diff --git a/examples/example_vs.cpp b/examples/example_vs.cpp
index 974c2b0f2..108577b45 100644
--- a/examples/example_vs.cpp
+++ b/examples/example_vs.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include "crow.h"
#include
@@ -10,7 +9,7 @@ class ExampleLogHandler : public crow::ILogHandler {
}
};
-struct ExampleMiddleware
+struct ExampleMiddleware
{
std::string message;
@@ -108,7 +107,7 @@ int main()
app.route_dynamic("/params")
([](const crow::request& req){
std::ostringstream os;
- os << "Params: " << req.url_params << "\n\n";
+ os << "Params: " << req.url_params << "\n\n";
os << "The key 'foo' was " << (req.url_params.get("foo") == nullptr ? "not " : "") << "found.\n";
if(req.url_params.get("pew") != nullptr) {
double countD = boost::lexical_cast(req.url_params.get("pew"));
@@ -120,7 +119,7 @@ int main()
os << " - " << countVal << '\n';
}
return crow::response{os.str()};
- });
+ });
// ignore all log
crow::logger::setLogLevel(crow::LogLevel::Debug);
diff --git a/examples/example_with_all.cpp b/examples/example_with_all.cpp
index 2ab5fc8b8..8f0f028bc 100644
--- a/examples/example_with_all.cpp
+++ b/examples/example_with_all.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include "crow_all.h"
#include
@@ -96,7 +95,7 @@ int main()
CROW_ROUTE(app, "/params")
([](const crow::request& req){
std::ostringstream os;
- os << "Params: " << req.url_params << "\n\n";
+ os << "Params: " << req.url_params << "\n\n";
os << "The key 'foo' was " << (req.url_params.get("foo") == nullptr ? "not " : "") << "found.\n";
if(req.url_params.get("pew") != nullptr) {
double countD = boost::lexical_cast(req.url_params.get("pew"));
@@ -108,7 +107,7 @@ int main()
os << " - " << countVal << '\n';
}
return crow::response{os.str()};
- });
+ });
// ignore all log
crow::logger::setLogLevel(crow::LogLevel::Debug);
diff --git a/examples/helloworld.cpp b/examples/helloworld.cpp
index c12b8c41e..2a44c65c3 100644
--- a/examples/helloworld.cpp
+++ b/examples/helloworld.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include "crow.h"
int main()
diff --git a/examples/ssl/example_ssl.cpp b/examples/ssl/example_ssl.cpp
index 71b362ff3..a8a1cfc5c 100644
--- a/examples/ssl/example_ssl.cpp
+++ b/examples/ssl/example_ssl.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include "crow.h"
int main()
@@ -14,7 +13,7 @@ int main()
// Use .pem file
//app.port(18080).ssl_file("test.pem").run();
-
+
// Use custom context; see boost::asio::ssl::context
/*
* crow::ssl_context_t ctx;
diff --git a/examples/websocket/example_ws.cpp b/examples/websocket/example_ws.cpp
index 7ad0d5d12..bc2832b40 100644
--- a/examples/websocket/example_ws.cpp
+++ b/examples/websocket/example_ws.cpp
@@ -1,4 +1,3 @@
-#define CROW_MAIN
#include "crow.h"
#include
#include
@@ -38,7 +37,7 @@ int main()
gethostname(name, 256);
crow::mustache::context x;
x["servername"] = name;
-
+
auto page = crow::mustache::load("ws.html");
return page.render(x);
});
diff --git a/include/crow/http_response.h b/include/crow/http_response.h
index 5eedce065..aad683acd 100644
--- a/include/crow/http_response.h
+++ b/include/crow/http_response.h
@@ -78,7 +78,7 @@ namespace crow
{
*this = std::move(r);
}
-
+
response(std::string contentType, std::string body) : body(std::move(body))
{
set_header("Content-Type", mime_types.at(contentType));
diff --git a/tests/ssl/ssltest.cpp b/tests/ssl/ssltest.cpp
index 901d2b855..d803be747 100644
--- a/tests/ssl/ssltest.cpp
+++ b/tests/ssl/ssltest.cpp
@@ -1,6 +1,5 @@
#define CATCH_CONFIG_MAIN
#define CROW_LOG_LEVEL 0
-#define CROW_MAIN
#include
diff --git a/tests/unittest.cpp b/tests/unittest.cpp
index 9eb846a83..5937bff7e 100644
--- a/tests/unittest.cpp
+++ b/tests/unittest.cpp
@@ -1,7 +1,6 @@
#define CATCH_CONFIG_MAIN
#define CROW_ENABLE_DEBUG
#define CROW_LOG_LEVEL 0
-#define CROW_MAIN
#include
#include