Handling REST Delete request CPPRESTSDK

84 Views Asked by At

I want to handle delete request on server side by using cpprestsdk. But the problem is the end part of url is string and can contain any value. ex http://127.0.0.1/subscriptions/{"it is id in string format"}. How to create a single listener for that?.

Do I need to create a separate listener for seperate id .Like one http listener for http://127.0.0.1/subscriptions/1 another http listener for http://127.0.0.1/subscriptions/2

I think this method is ugly.

1

There are 1 best solutions below

0
Renju Ashokan On

The request is can be written as subscriptions/{id}

void handle_delete(http_request request)
{
   // Get the value of the "id" parameter from the URI
    auto id = request.relative_uri().path().substr(15); // 15 is the length at wich id starts
}