diff --git a/.gitignore b/.gitignore index 2837b7f5c..ec63977d3 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ unittest covtest *.gcda *.gcno + +.directory diff --git a/Makefile b/Makefile index 74f9f89ae..cc7f9d6a1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ +binaries=covtest example + all: covtest example + example: example.cpp settings.h crow.h http_server.h http_connection.h parser.h http_response.h routing.h common.h utility.h json.h datetime.h logging.h - g++ -Wall -g -O3 -std=c++11 -o example example.cpp http-parser/http_parser.c -pthread -lboost_system -lboost_thread -ltcmalloc_minimal -I http-parser/ + ${CXX} -Wall -g -O3 -std=c++1y -o example example.cpp http-parser/http_parser.c -pthread -lboost_system -lboost_thread -ltcmalloc_minimal -I http-parser/ test: covtest @@ -11,12 +14,15 @@ runtest: example pkill example unittest: unittest.cpp routing.h utility.h crow.h http_server.h http_connection.h parser.h http_response.h common.h json.h datetime.h logging.h - g++ -Wall -g -std=c++11 -o unittest unittest.cpp http-parser/http_parser.c -pthread -lboost_system -lboost_thread -I http-parser/ + ${CXX} -Wall -g -std=c++1y -o unittest unittest.cpp http-parser/http_parser.c -pthread -lboost_system -lboost_thread -I http-parser/ ./unittest covtest: unittest.cpp routing.h utility.h crow.h http_server.h http_connection.h parser.h http_response.h common.h json.h datetime.h logging.h - g++ -Wall -g -std=c++11 -o covtest --coverage unittest.cpp http-parser/http_parser.c -pthread -lboost_system -lboost_thread -I http-parser/ + ${CXX} -Wall -g -std=c++1y -o covtest --coverage unittest.cpp http-parser/http_parser.c -pthread -lboost_system -lboost_thread -I http-parser/ ./covtest gcov -r unittest.cpp +.PHONY: clean +clean: + rm -f $(binaries) *.o diff --git a/README.md b/README.md index a47140f9d..783593b05 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,10 @@ -Crow -==== +# Crow Crow is C++ microframework for web. (inspired by Python Flask) (still in development, not completed yet) -Example -======= +## Example ```c++ @@ -69,5 +67,10 @@ int main() .multithreaded() .run(); } - ``` + +## How to Build + +### Ubuntu + sudo apt-get install build-essential libtcmalloc-minimal4 && sudo ln -s /usr/lib/libtcmalloc_minimal.so.4 /usr/lib/libtcmalloc_minimal.so + make -j$(($(grep -c '^processor' /proc/cpuinfo)+1)) diff --git a/crow.h b/crow.h index 82294e73a..025d174c3 100644 --- a/crow.h +++ b/crow.h @@ -1,9 +1,10 @@ #pragma once + #include #include #include #include -#include +#include #include #include diff --git a/http_connection.h b/http_connection.h index b90d5edca..4d396418e 100644 --- a/http_connection.h +++ b/http_connection.h @@ -229,7 +229,7 @@ namespace crow HTTPParser parser_; response res; - int life_; + int life_ {}; bool close_connection_ = false; const std::string& server_name_; diff --git a/http_server.h b/http_server.h index 3ca88f263..aa3124e46 100644 --- a/http_server.h +++ b/http_server.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include "http_connection.h" @@ -12,6 +12,7 @@ namespace crow { using namespace boost; using tcp = asio::ip::tcp; + template class Server { diff --git a/json.h b/json.h index d3b9839dc..1e4a7c202 100644 --- a/json.h +++ b/json.h @@ -939,7 +939,7 @@ namespace crow type t() { return t_; } private: type t_{type::Null}; - double d; + double d {}; std::string s; std::unique_ptr> l; std::unique_ptr> o; diff --git a/logging.h b/logging.h index 303e85722..b43a969dd 100644 --- a/logging.h +++ b/logging.h @@ -2,12 +2,14 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include +#include "settings.h" + using namespace std; namespace crow diff --git a/routing.h b/routing.h index c3be5fdd5..3a8b7abe5 100644 --- a/routing.h +++ b/routing.h @@ -11,6 +11,7 @@ #include "http_response.h" #include "http_request.h" #include "utility.h" +#include "logging.h" namespace crow { @@ -182,7 +183,7 @@ namespace crow void operator()(std::string name, Func&& f) { name_ = std::move(name); - (*this).operator()(std::forward(f)); + (*this).template operator()(std::forward(f)); } response handle(const request& req, const routing_params& params) diff --git a/utility.h b/utility.h index 4187dd70c..a46d5771f 100644 --- a/utility.h +++ b/utility.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include namespace crow