aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile12
-rw-r--r--README.md13
-rw-r--r--crow.h3
-rw-r--r--http_connection.h2
-rw-r--r--http_server.h3
-rw-r--r--json.h2
-rw-r--r--logging.h8
-rw-r--r--routing.h3
-rw-r--r--utility.h2
10 files changed, 33 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index 2837b7f..ec63977 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,5 @@ unittest
covtest
*.gcda
*.gcno
+
+.directory
diff --git a/Makefile b/Makefile
index 74f9f89..cc7f9d6 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 a47140f..783593b 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 82294e7..025d174 100644
--- a/crow.h
+++ b/crow.h
@@ -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
{
diff --git a/json.h b/json.h
index d3b9839..1e4a7c2 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<std::vector<wvalue>> l;
std::unique_ptr<std::unordered_map<std::string, wvalue>> o;
diff --git a/logging.h b/logging.h
index 303e857..b43a969 100644
--- a/logging.h
+++ b/logging.h
@@ -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
diff --git a/routing.h b/routing.h
index c3be5fd..3a8b7ab 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()<Func>(std::forward(f));
+ (*this).template operator()<Func>(std::forward(f));
}
response handle(const request& req, const routing_params& params)
diff --git a/utility.h b/utility.h
index 4187dd7..a46d577 100644
--- a/utility.h
+++ b/utility.h
@@ -1,6 +1,6 @@
#pragma once
-#include <stdint.h>
+#include <cstdint>
#include <stdexcept>
namespace crow