Browse Source

...

master
Volker Birk 2 years ago
parent
commit
d509faacf6
2 changed files with 17 additions and 1 deletions
  1. +16
    -1
      webserver.cc
  2. +1
    -0
      webserver.hh

+ 16
- 1
webserver.cc View File

@ -67,6 +67,11 @@ void Webserver::remove_url_handler(std::string url_regex) {
_urls.erase(url_regex);
}
void Webserver::deliver_file(boost::string_view target)
{
}
Webserver::handler_t Webserver::find_handler(request& r, boost::cmatch& m)
{
for (auto it=_urls.begin(); it!=_urls.end(); ++it) {
@ -91,7 +96,17 @@ void Webserver::do_session(tcp::socket *socket)
if (ec)
return fail(ec, "reading from stream");
boost::cmatch m;
Webserver::response *resp = nullptr;
Webserver::handler_t handler = find_handler(req, m);
if (handler) {
resp = handler(m, req);
}
else {
deliver_file(req.target());
}
delete resp;
}
socket->shutdown(tcp::socket::shutdown_send, ec);


+ 1
- 0
webserver.hh View File

@ -52,6 +52,7 @@ namespace pEp {
void shutdown();
protected:
void deliver_file(boost::string_view target);
handler_t find_handler(request& r, boost::cmatch& m);
void do_session(tcp::socket *socket);
};


Loading…
Cancel
Save