File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ macro(run_conan)
1818 sml/1.1.5
1919 nlohmann_json/3.10.5
2020 boost/1.78.0
21+ crowcpp-crow/1.0+1
2122 OPTIONS
2223 ${CONAN_EXTRA_OPTIONS}
2324 gtest:build_gmock=True
Original file line number Diff line number Diff line change 11OPTION (CPP_STARTER_USE_SML "Enable compilation of SML sample" OFF )
22OPTION (CPP_STARTER_USE_BOOST_BEAST "Enable compilation of boost beast sample" OFF )
3+ OPTION (CPP_STARTER_USE_CROW "Enable compilation of crow sample" OFF )
34
45# SML
56IF (CPP_STARTER_USE_SML)
@@ -13,6 +14,12 @@ IF(CPP_STARTER_USE_BOOST_BEAST)
1314 ADD_SUBDIRECTORY (boost.beast )
1415ENDIF ()
1516
17+ # Crow
18+ IF (CPP_STARTER_USE_BOOST_BEAST)
19+ MESSAGE ("Using Crow" )
20+ ADD_SUBDIRECTORY (crow )
21+ ENDIF ()
22+
1623
1724# Generic test that uses conan libs
1825ADD_EXECUTABLE (intro main.cpp )
@@ -23,4 +30,3 @@ TARGET_LINK_LIBRARIES(
2330 CONAN_PKG::docopt.cpp
2431 CONAN_PKG::fmt
2532 CONAN_PKG::spdlog )
26-
Original file line number Diff line number Diff line change 1+ ADD_EXECUTABLE (test_crow main.cpp )
2+ TARGET_LINK_LIBRARIES (test_crow PRIVATE CONAN_PKG::crowcpp-crow CONAN_PKG::spdlog )
Original file line number Diff line number Diff line change 1+ /* example usage of crow-cpp http://crowcpp.org/ */
2+ #include " crow.h"
3+
4+ class a : public crow ::returnable
5+ {
6+ public:
7+ a () : returnable(" text/plain" ){};
8+
9+ std::string dump () const override
10+ {
11+ return " ABCDF" ;
12+ }
13+ };
14+
15+ int main ()
16+ {
17+ constexpr uint16_t port = 8080 ;
18+ std::vector<int > values;
19+ crow::SimpleApp app;
20+
21+ CROW_ROUTE (app, " /" )
22+ ([]() {
23+ return " Hello world" ;
24+ });
25+
26+ CROW_ROUTE (app, " /json" )
27+ ([] {
28+ crow::json::wvalue returnValue ({ { " message" , " Hello, World!" } });
29+ returnValue[" message2" ] = " Hello, World.. Again!" ;
30+ return returnValue;
31+ });
32+
33+ CROW_ROUTE (app, " /custom" )
34+ ([] {
35+ return a ();
36+ });
37+
38+ CROW_ROUTE (app, " /hello/<int>" ).methods (crow::HTTPMethod::POST)([&values](int count) {
39+ values.push_back (count);
40+ return crow::response (std::to_string (count));
41+ });
42+
43+ CROW_ROUTE (app, " /hello/" ).methods (crow::HTTPMethod::GET)([&values]() {
44+ crow::json::wvalue returnValue;
45+ returnValue[" values" ] = values;
46+ return returnValue;
47+ });
48+
49+ app.port (port).run ();
50+ return 0 ;
51+ }
You can’t perform that action at this time.
0 commit comments