Dynamic URL with HTTP_Listener

Jan 5, 2016 at 4:52 AM
Good morning,

i wrote a simple constructor for a http_listener with a static url.
Everything works fine, but how can i fill the variables before the call, and use them in the constructor?


Here is my call
//string url = "http://localhost:4711";

    utility::string_t url;
    utility::string_t port;
    
    Commanagement *Com = new Commanagement(url,port);
And this is my constructor
void Commanagement::Init(utility::string_t url, utility::string_t port)
{
    this->url = &url;
    this->port = &port;
    
    listener = new http_listener(U("http://localhost:4711"));//How to do this Variable with my port and url?
    listener = new http_listener();
    listener->support(methods::GET, std::bind(&Commanagement::handle_GET, this, std::placeholders::_1));
    listener->support(methods::POST, std::bind(&Commanagement::handle_POST, this, std::placeholders::_1));
    listener->open().wait();
}
Jan 7, 2016 at 8:26 PM
Sometimes it´s simple.
utility::string_t address = U("http://localhost:");
utility::string_t port = U("4711");

address.append(port);
listener = new http_listener(address);

Marked as answer by Cazzador on 1/7/2016 at 1:27 PM