#include "httpd.h" #include HTTP::Server::Server(boost::asio::io_service& io_service, const tcp::endpoint& endpoint) : acceptor_(io_service, endpoint) { start_accept(); } void HTTP::Server::add_handler(const std::string& name, Handler handler) { handlers[name] = handler; } void HTTP::Server::start_accept() { Connection::p new_connection = Connection::p(new Connection(acceptor_.io_service())); acceptor_.async_accept(new_connection->socket, boost::bind(&Server::handle_accept, this, new_connection, boost::asio::placeholders::error)); } void HTTP::Server::handle_accept(Connection::p new_connection, const boost::system::error_code& error) { if(!error) { new_connection->start(); start_accept(); } }