* 'master' of https://phabricator.tomicevic.com/diffusion/MG/memgraph:
  Lexertl git submodule
  Initial version of the router class (not yet implemented)
This commit is contained in:
Dominik Tomičević 2015-09-17 21:40:37 +02:00
commit 65d1920af5
14 changed files with 87 additions and 22 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.DS_Store
.ycm_extra_conf.py
.ycm_extra_conf.pyc
*.swp

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "cypher/lexertl"]
path = cypher/lexertl
url = https://github.com/BenHanson/lexertl.git

1
cypher/.gitignore vendored
View File

@ -1,4 +1,3 @@
lexertl
lemon
*.o
cypher.cpp

View File

@ -17,7 +17,7 @@ cypher.hpp: lemonfiles
.PHONY: lemonfiles
lemonfiles: cypher.y
lemon/lemon cypher.y -s
lemon cypher.y -s
mv cypher.c cypher.cpp
.PHONY: clean

View File

@ -1,6 +1,4 @@
#include "lexertl/generator.hpp"
#include <iostream>
#include "lexertl/lookup.hpp"
#include "cypher_lexer.hpp"

View File

@ -8,8 +8,8 @@
// auto_ptr<lexertl::detail::basic_re_token<char, char> > is deprecated
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#include "lexertl/generator.hpp"
#include "lexertl/lookup.hpp"
#include "lexertl/lexertl/generator.hpp"
#include "lexertl/lexertl/lookup.hpp"
#pragma GCC diagnostic pop
#include "errors.hpp"

1
cypher/lexertl Submodule

@ -0,0 +1 @@
Subproject commit 5acf39fbea01eb546edd140ce1334bd53f88928f

1
server/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.out

View File

@ -2,7 +2,7 @@
* https://github.com/libuv/libuv
```{engine='bash'}
```
sh autogen.sh
./configure
make
@ -12,14 +12,20 @@ make install
* https://github.com/joyent/http-parser
```{engine='bash'}
```
make
make install -stdlib=libstdc++ -lstdc++ (OSX)
make install
```
* https://github.com/c9s/r3
```
brew install r3 (OSX)
```
## Test compile
```{engine='bash'}
clang++ -std=c++11 test.cpp -o test -luv -lhttp_parser -I../
```
```
clang++ -std=c++11 test.cpp -o test.out -luv -lhttp_parser -I../
```

View File

@ -0,0 +1,3 @@
#include "router.hpp"
#include "router.inl"

View File

@ -0,0 +1,27 @@
#ifndef MEMGRAPH_SERVER_APPLICATION_ROUTER_HPP
#define MEMGRAPH_SERVER_APPLICATION_ROUTER_HPP
// TODO: find more appropriate way to include header files
#include "../uv/uv.hpp"
#include "../http/http.hpp"
namespace application
{
// TODO: find out more appropriate name, like express
class Router
{
private:
uv::UvLoop loop;
http::HttpServer server;
http::Ipv4 ip;
public:
Router(const http::Ipv4& ip);
void get(const std::string path, http::request_cb_t callback);
void listen();
~Router();
};
}
#endif

View File

@ -0,0 +1,34 @@
#ifndef MEMGRAPH_SERVER_APPLICATION_ROUTER_INL
#define MEMGRAPH_SERVER_APPLICATION_ROUTER_INL
#include "router.hpp"
namespace application
{
Router::Router(const http::Ipv4& ip) : server(loop), ip(ip)
{
}
void Router::get(const std::string path, http::request_cb_t callback)
{
}
void Router::listen()
{
server.listen(ip, [](http::Request& req, http::Response& res) {
res.send(req.url);
});
std::cout << "Server is UP" << std::endl;
loop.run(uv::UvLoop::Mode::Default);
}
Router::~Router()
{
}
}
#endif

View File

@ -1,19 +1,13 @@
#include <iostream>
#include "uvmachine.hpp"
#include "application/application.hpp"
int main(void)
{
uv::UvLoop loop;
http::HttpServer server(loop);
http::Ipv4 ip("0.0.0.0", 3400);
server.listen(ip, [](http::Request& req, http::Response& res) {
res.send(req.url);
});
loop.run(uv::UvLoop::Mode::Default);
application::Router router(ip);
router.listen();
return 0;
}

View File

@ -1,2 +0,0 @@
#include "uv/uv.hpp"
#include "http/http.hpp"