I use REST API based system, in which there are some requests that take long time to complete. I want to give user an option to cancel the request.
First, support
POST /requests
which will return a reference to the status of the request
{
"id": 1234,
"self"": "/requests/1234"
"status": "Running"
}
Then add support for
PUT /requests/1234
{
"status": "Canceled:"
}
That will let clients cancel a request if it hasn't finished yet. If the request is to create some other kind of resource, then instead of POST /requests
, do POST /myResource
, but still return the status object with the pointer to /requests in the response.
Clients can then poll /requests
to see when the request is complete.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With