|
|
@ -1,13 +1,24 @@ |
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <boost/asio/ip/tcp.hpp>
|
|
|
|
#include <boost/regex.hpp>
|
|
|
|
|
|
|
|
namespace net = boost::asio; |
|
|
|
using namespace std; |
|
|
|
using tcp = boost::asio::ip::tcp; |
|
|
|
|
|
|
|
namespace pEp { |
|
|
|
class Webserver { |
|
|
|
net::io_context _ioc; |
|
|
|
tcp::acceptor _acceptor; |
|
|
|
std::string _doc_root; |
|
|
|
public: |
|
|
|
typedef boost::regex url_t; |
|
|
|
typedef std::function< void(boost::cmatch) > handler_t; |
|
|
|
|
|
|
|
private: |
|
|
|
net::io_context _ioc; |
|
|
|
tcp::acceptor _acceptor; |
|
|
|
std::string _doc_root; |
|
|
|
std::vector< std::pair< url_t, handler_t > > _urls; |
|
|
|
|
|
|
|
public: |
|
|
|
Webserver(net::ip::address addr, unsigned short port, std::string doc_root); |
|
|
@ -15,6 +26,7 @@ namespace pEp { |
|
|
|
Webserver& operator=(const Webserver&) = delete; |
|
|
|
~Webserver() { } |
|
|
|
|
|
|
|
void add_url_handler(url_t url, handler_t handler); |
|
|
|
void run(); |
|
|
|
|
|
|
|
protected: |
|
|
|