Browse Source

...

master
Volker Birk 2 years ago
parent
commit
92cbe2f95b
2 changed files with 7 additions and 3 deletions
  1. +1
    -2
      webserver.cc
  2. +6
    -1
      webserver.hh

+ 1
- 2
webserver.cc View File

@ -22,7 +22,6 @@ namespace pEp {
Webserver::Webserver(net::ip::address addr, unsigned short port, std::string doc_root)
: _ioc(1), _acceptor(_ioc, {addr, port}), _doc_root(doc_root), _running(false) { }
// Return a reasonable mime type based on the extension of a file.
static beast::string_view mime_type(beast::string_view path)
{
using beast::iequals;
@ -70,7 +69,7 @@ void Webserver::do_session(tcp::socket& socket)
// This lambda is used to send messages
// send_lambda<tcp::socket> lambda{socket, close, ec};
for(;;)
while (_running)
{
// Read a request
http::request<http::string_body> req;


+ 6
- 1
webserver.hh View File

@ -4,7 +4,10 @@
#include <vector>
#include <boost/asio/ip/tcp.hpp>
#include <boost/regex.hpp>
#include <boost/beast/http.hpp>
namespace beast = boost::beast;
namespace http = beast::http;
namespace net = boost::asio;
using tcp = boost::asio::ip::tcp;
@ -19,7 +22,9 @@ namespace pEp {
class Webserver {
public:
typedef boost::regex url_t;
typedef std::function< void(boost::cmatch) > handler_t;
typedef http::message< true, http::string_body > request;
typedef http::message< false, http::string_body > response;
typedef std::function< response(boost::cmatch, request) > handler_t;
private:
net::io_context _ioc;


Loading…
Cancel
Save