memgraph/speedy/speedy.hpp

75 lines
1.7 KiB
C++
Raw Normal View History

2015-09-27 19:18:50 +08:00
/** @file speedy.hpp
* @brief Speedy - Cpp Web Application Framework
*
* Blazingly fast web application framework. Designed like
* http://expressjs.com, one of its mail goal is also simple usage.
*
* @author Dominik Tomicevic (domko)
* @author Marko Budiselic (buda)
*/
#ifndef MEMGRAPH_SPEEDY_HPP
#define MEMGRAPH_SPEEDY_HPP
#include <vector>
2015-09-20 20:30:26 +08:00
#include "io/uv/uv.hpp"
#include "http/http.hpp"
#include "r3_include.h"
namespace speedy
{
typedef unsigned int uint;
class Speedy
{
private:
2015-09-27 19:18:50 +08:00
/*
* http server instance that contains all logic related
* to the http protocol
*/
http::HttpServer server;
2015-09-27 19:18:50 +08:00
/*
* ip address of the server
*/
http::Ipv4 ip;
2015-09-27 19:18:50 +08:00
/*
* root node of r3 decision tree
*/
node *n;
2015-09-27 19:18:50 +08:00
/*
* callbacks container
*/
std::vector<http::request_cb_t> callbacks;
2015-09-27 19:18:50 +08:00
/** @brief Store a http callback.
*
* Every callback for now has receiving method and path (url).
* So, the implementation of this method saves callback for
* the method and the path.
*
* @param method int http defined method
* @param path std::string path (url)
* @param callback http::request_cb_t callback which will be called
* on a http request
*/
2015-09-25 05:25:40 +08:00
void store_callback(int method,
const std::string &path,
http::request_cb_t callback);
public:
2015-09-20 20:30:26 +08:00
Speedy(uv::UvLoop& loop, const http::Ipv4& ip);
void get(const std::string &path, http::request_cb_t callback);
void post(const std::string &path, http::request_cb_t callback);
void put(const std::string &path, http::request_cb_t callback);
void del(const std::string &path, http::request_cb_t callback);
void listen();
};
}
#include "speedy.inl"
#endif