Web server part of the project was renamed. The new name is speedy

This commit is contained in:
buda 2015-09-18 19:49:23 +02:00
parent 03e7999e53
commit 6939ee9769
36 changed files with 96 additions and 86 deletions

View File

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

View File

@ -1,27 +0,0 @@
#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

@ -1,34 +0,0 @@
#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,13 +0,0 @@
#include <iostream>
#include "application/application.hpp"
int main(void)
{
http::Ipv4 ip("0.0.0.0", 3400);
application::Router router(ip);
router.listen();
return 0;
}

20
speedy/Makefile Normal file
View File

@ -0,0 +1,20 @@
CXX=clang++
CFLAGS=-std=c++11 -Wall
LDFLAGS=-luv -lhttp_parser
INC=-I./
SOURCES=$(wildcard *.cpp)
EXECUTABLE=test.out
# OBJECTS=$(SOURCES:.cpp=.o)
all: $(EXECUTABLE)
$(EXECUTABLE): $(SOURCES)
$(CXX) $(LDFLAGS) $(SOURCES) -o $(EXECUTABLE) $(CFLAGS)
# .cpp.o:
# $(CXX) $(CFLAGS) $< -o $@ $(LDFLAGS) $(INC)
.PHONY:
clean:
rm -f *.out
rm -f *.o

View File

@ -23,9 +23,3 @@ make install
``` ```
brew install r3 (OSX) brew install r3 (OSX)
``` ```
## Test compile
```
clang++ -std=c++11 test.cpp -o test.out -luv -lhttp_parser -I../
```

View File

@ -1,7 +1,7 @@
#ifndef MEMGRAPH_SERVER_HTTP_CONNECTION_HPP #ifndef MEMGRAPH_SERVER_HTTP_CONNECTION_HPP
#define MEMGRAPH_SERVER_HTTP_CONNECTION_HPP #define MEMGRAPH_SERVER_HTTP_CONNECTION_HPP
#include "server/uv/uv.hpp" #include "uv/uv.hpp"
#include "httpparser.hpp" #include "httpparser.hpp"
#include "request.hpp" #include "request.hpp"

View File

@ -4,7 +4,7 @@
#include <iostream> #include <iostream>
#include <uv.h> #include <uv.h>
#include "server/uv/uv.hpp" #include "uv/uv.hpp"
#include "httpparsersettings.hpp" #include "httpparsersettings.hpp"
#include "httpconnection.hpp" #include "httpconnection.hpp"
#include "request.hpp" #include "request.hpp"

View File

@ -3,7 +3,7 @@
#include <map> #include <map>
#include "server/uv/uv.hpp" #include "uv/uv.hpp"
#include "status_codes.hpp" #include "status_codes.hpp"
namespace http namespace http

27
speedy/speedy.hpp Normal file
View File

@ -0,0 +1,27 @@
#ifndef MEMGRAPH_SPEEDY_HPP
#define MEMGRAPH_SPEEDY_HPP
#include "http/uv/uv.hpp"
#include "http/http.hpp"
namespace speedy
{
class Speedy
{
private:
uv::UvLoop loop;
http::HttpServer server;
http::Ipv4 ip;
public:
Speedy(const http::Ipv4& ip);
void get(const std::string path, http::request_cb_t callback);
void listen();
~Speedy();
};
}
#include "speedy.inl"
#endif

34
speedy/speedy.inl Normal file
View File

@ -0,0 +1,34 @@
#ifndef MEMGRAPH_SPEEDY_INL
#define MEMGRAPH_SPEEDY_INL
#include "speedy.hpp"
namespace speedy
{
Speedy::Speedy(const http::Ipv4& ip) : server(loop), ip(ip)
{
}
void Speedy::get(const std::string path, http::request_cb_t callback)
{
}
void Speedy::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);
}
Speedy::~Speedy()
{
}
}
#endif

12
speedy/test.cpp Normal file
View File

@ -0,0 +1,12 @@
#include <iostream>
#include "speedy.hpp"
int main(void)
{
http::Ipv4 ip("0.0.0.0", 3400);
speedy::Speedy app(ip);
app.listen();
return 0;
}