Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: Extracting the parts of a path using Listener and split_path

$
0
0
Given the following code
    listener.support(methods::GET, [](http_request request) {
        string_t path;
        string_t host;
        int port;

        std::vector<utility::string_t> splitPath;

        try {

            path = request.relative_uri().path();
            host = request.relative_uri().host();
            port = request.relative_uri().port();

            splitPath = request.relative_uri().split_path(path);

            std::cout << splitPath.at[1] << std::endl;

            request.reply(http::status_codes::OK, U("Request Recieved!!!"));
        }
        catch (std::exception& e) {
            // TODO: log this
            std::cout << e.what() << std::endl;
        }
    });
I am trying to get each entry in the path but the above code does not compile - the following line fails with
error C3867: 'std::vector<utility::string_t,std::allocator<_Ty>>::at': function call missing argument list; use '&std::vector<utility::string_t,std::allocator<_Ty>>::at' to create a pointer to member c:\users\paul\documents\visual studio 2013\projects\dataengine\dataengine\messagelistener.cpp   34  1   DataEngine
and
Error   2   error C2109: subscript requires array or pointer type   c:\users\paul\documents\visual studio 2013\projects\dataengine\dataengine\messagelistener.cpp   34  1   DataEngine
I'm trying to learn C++ at the same time can anyone help?

Thanks in advance

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>