Reputation: 1487
I would like to get the URI called with boost.
If http://localhost:8080/users/4
is called, I want to know the URI or just /users/4
#include <boost/bind.hpp>
#include <boost/asio.hpp>
using boost::asio::ip::tcp;
int main()
{
boost::asio::io_service io;
tcp::acceptor acceptor(io, tcp::endpoint(tcp::v4(), 8080));
tcp::socket socket(io);
acceptor.accept(socket);
// Do stuff to get URI
// ...
if (uri == "http://localhost:8080/users/4") {
std::cout << "User 4 uri called" << std::endl;
}
return 0;
}
Upvotes: 2
Views: 491
Reputation: 8660
Look to the ASIO's http server example. The connection::handle_read
method parses a request, using the request_parser
class instance, as result, an instance of the request
structure contains an URI which is required.
Upvotes: 2