mirror of https://github.com/CrowCpp/Crow.git
Add vcpkg.json to download Boost, openssl and zlib. Edit docs/getting-started/setup.md to show a simple setup with example_with_all.cpp.
This commit is contained in:
parent
3bd1956e90
commit
44abb2d327
|
@ -53,8 +53,19 @@ To build a crow Project, do the following:
|
|||
- 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`.
|
||||
|
||||
###Microsoft Visual Studio
|
||||
***Help needed***
|
||||
###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`
|
||||
4. `.\vcpkg\vcpkg integrate install`
|
||||
5. Create empty Visual Studio project.
|
||||
6. In solution explorer, right click the name of your project then click `Open Folder in File Explorer`.
|
||||
7. Copy `crow_all.h`, `example_with_all.cpp`, `vcpkg.json` to opened folder.
|
||||
8. Add `crow_all.h` to `Header Files` and `example_with_all.cpp` to `Source Files`.
|
||||
9. In solution explorer, right click the name of your project then click `Properties`.
|
||||
10. Under `vcpkg`, set `Use Vcpkg Manifest` to `Yes` and `Additional Options` to `--feature-flags="versions"`.
|
||||
11. Set `Debug/Release` and `x64/x86`.
|
||||
12. Run.
|
||||
|
||||
|
||||
##building via CMake
|
||||
|
|
|
@ -44,31 +44,32 @@ int main()
|
|||
|
||||
app.get_middleware<ExampleMiddleware>().setMessage("hello");
|
||||
|
||||
app.route_dynamic("/")
|
||||
CROW_ROUTE(app, "/")
|
||||
.name("hello")
|
||||
([]{
|
||||
return "Hello World!";
|
||||
});
|
||||
|
||||
app.route_dynamic("/about")
|
||||
CROW_ROUTE(app, "/about")
|
||||
([](){
|
||||
return "About Crow example.";
|
||||
});
|
||||
|
||||
// a request to /path should be forwarded to /path/
|
||||
app.route_dynamic("/path/")
|
||||
CROW_ROUTE(app, "/path/")
|
||||
([](){
|
||||
return "Trailing slash test case..";
|
||||
});
|
||||
|
||||
// simple json response
|
||||
app.route_dynamic("/json")
|
||||
CROW_ROUTE(app, "/json")
|
||||
([]{
|
||||
crow::json::wvalue x;
|
||||
x["message"] = "Hello, World!";
|
||||
return x;
|
||||
});
|
||||
|
||||
app.route_dynamic("/hello/<int>")
|
||||
CROW_ROUTE(app, "/hello/<int>")
|
||||
([](int count){
|
||||
if (count > 100)
|
||||
return crow::response(400);
|
||||
|
@ -77,7 +78,7 @@ int main()
|
|||
return crow::response(os.str());
|
||||
});
|
||||
|
||||
app.route_dynamic("/add/<int>/<int>")
|
||||
CROW_ROUTE(app, "/add/<int>/<int>")
|
||||
([](crow::response& res, int a, int b){
|
||||
std::ostringstream os;
|
||||
os << a+b;
|
||||
|
@ -92,7 +93,7 @@ int main()
|
|||
//});
|
||||
|
||||
// more json example
|
||||
app.route_dynamic("/add_json")
|
||||
CROW_ROUTE(app, "/add_json")
|
||||
.methods(crow::HTTPMethod::Post)
|
||||
([](const crow::request& req){
|
||||
auto x = crow::json::load(req.body);
|
||||
|
@ -129,3 +130,8 @@ int main()
|
|||
.multithreaded()
|
||||
.run();
|
||||
}
|
||||
|
||||
Edit example_vs.cpp to use CROW_ROUTE instead of app.route_dynamic.
|
||||
|
||||
VS2019 error:
|
||||
'<function-style-cast>': cannot convert from 'void' to 'crow::response'
|
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
"name": "crow-examples",
|
||||
"version": "0.2",
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "boost-array",
|
||||
"version>=": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-algorithm",
|
||||
"version>=": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-asio",
|
||||
"version>=": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-date-time",
|
||||
"version>=": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-functional",
|
||||
"version>=": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-lexical-cast",
|
||||
"version>=": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-optional",
|
||||
"version>=": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "openssl-windows"
|
||||
},
|
||||
{
|
||||
"name": "zlib"
|
||||
}
|
||||
],
|
||||
"overrides": [
|
||||
{
|
||||
"name": "boost-array",
|
||||
"version": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-algorithm",
|
||||
"version": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-asio",
|
||||
"version-semver": "1.70.0-2"
|
||||
},
|
||||
{
|
||||
"name": "boost-date-time",
|
||||
"version": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-functional",
|
||||
"version": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-lexical-cast",
|
||||
"version": "1.70.0"
|
||||
},
|
||||
{
|
||||
"name": "boost-optional",
|
||||
"version": "1.70.0"
|
||||
}
|
||||
],
|
||||
"builtin-baseline": "44d94c2edbd44f0c01d66c2ad95eb6982a9a61bc"
|
||||
}
|
Loading…
Reference in New Issue