Merge pull request #4 from dZkF9RWJT6wN8ux/master

Some fixes
This commit is contained in:
ipkn 2014-07-09 09:23:37 +09:00
commit 31d2e07bc2
10 changed files with 33 additions and 17 deletions

2
.gitignore vendored
View File

@ -29,3 +29,5 @@ unittest
covtest
*.gcda
*.gcno
.directory

View File

@ -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

View File

@ -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))

3
crow.h
View File

@ -1,9 +1,10 @@
#pragma once
#include <string>
#include <functional>
#include <memory>
#include <future>
#include <stdint.h>
#include <cstdint>
#include <type_traits>
#include <thread>

View File

@ -229,7 +229,7 @@ namespace crow
HTTPParser<Connection> parser_;
response res;
int life_;
int life_ {};
bool close_connection_ = false;
const std::string& server_name_;

View File

@ -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
{

2
json.h
View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -1,6 +1,6 @@
#pragma once
#include <stdint.h>
#include <cstdint>
#include <stdexcept>
namespace crow