diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 12 | ||||
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | crow.h | 3 | ||||
-rw-r--r-- | http_connection.h | 2 | ||||
-rw-r--r-- | http_server.h | 3 | ||||
-rw-r--r-- | json.h | 2 | ||||
-rw-r--r-- | logging.h | 8 | ||||
-rw-r--r-- | routing.h | 3 | ||||
-rw-r--r-- | utility.h | 2 |
10 files changed, 33 insertions, 17 deletions
@@ -29,3 +29,5 @@ unittest covtest *.gcda *.gcno + +.directory @@ -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 @@ -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)) @@ -1,9 +1,10 @@ #pragma once + #include <string> #include <functional> #include <memory> #include <future> -#include <stdint.h> +#include <cstdint> #include <type_traits> #include <thread> diff --git a/http_connection.h b/http_connection.h index b90d5ed..4d39641 100644 --- a/http_connection.h +++ b/http_connection.h @@ -229,7 +229,7 @@ namespace crow HTTPParser<Connection> 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 3ca88f2..aa3124e 100644 --- a/http_server.h +++ b/http_server.h @@ -1,7 +1,7 @@ #pragma once #include <boost/asio.hpp> -#include <stdint.h> +#include <cstdint> #include <atomic> #include "http_connection.h" @@ -12,6 +12,7 @@ namespace crow { using namespace boost; using tcp = asio::ip::tcp; + template <typename Handler> class Server { @@ -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<std::vector<wvalue>> l; std::unique_ptr<std::unordered_map<std::string, wvalue>> o; @@ -2,12 +2,14 @@ #include <string> #include <chrono> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> +#include <cstdio> +#include <cstdlib> +#include <ctime> #include <iostream> #include <sstream> +#include "settings.h" + using namespace std; namespace crow @@ -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()<Func>(std::forward(f)); + (*this).template operator()<Func>(std::forward(f)); } response handle(const request& req, const routing_params& params) @@ -1,6 +1,6 @@ #pragma once -#include <stdint.h> +#include <cstdint> #include <stdexcept> namespace crow |