5using namespace utility;
7using namespace web::http::experimental::listener;
11 listener.support(std::bind(&Server::handle,
this, std::placeholders::_1));
19void HTTP::Server::handle(http_request message)
21 for (
auto i = resources.begin(); i != resources.end(); i++)
24 std::string line = utility::conversions::to_utf8string(message.relative_uri().to_string());
25 std::regex regex(i->first);
26 if (std::regex_search(line, match, regex))
28 Response response = i->second->handle(message, match);
29 message.reply(response);
33 Response response = default_resource.handle(message);
34 message.reply(response);
41 resources.push_back(std::make_pair(path, resource));
46 for (
auto i = resources.begin(); i != resources.end(); i++)
void remove(std::string path)
Register resource.
Server(std::string url)
Constructor.
void add(std::string path, std::shared_ptr< Resource > resource)
Register resource.
web::http::http_response Response
HTTP Response.