Closed
Description
I have a JsonApi endpoint /prices
. When I submit a post request to this endpoint I would like to dispatch a job that is going to grab prices from a couple of external sources. I would like to return a response immediately that contains a reference to the dispatched job, like this: http://jsonapi.org/recommendations/#asynchronous-processing
This would be a high-level description of how I would solve this:
- Create a JsonApi endpoint for fetching the
job
resources. - Override the
create
method onPricesController
with some code to dispatch the price fetching job - Return a response containing a reference url to the
job
resource.
This would return something like this:
HTTP/1.1 202 Accepted
Content-Type: application/vnd.api+json
Content-Location: https://example.com/jobs/1234
{
"data": {
"type": "jobs",
"id": "1234",
"attributes": {
"status": "Pending request, waiting other process"
},
"links": {
"self": "/jobs/1234"
}
}
}
When the job is processed this endpoint returns:
HTTP/1.1 303 See other
Content-Type: application/vnd.api+json
Location: https://example.com/prices/4321
I think it would be nice if this package supports this recommendation. What do you think? I'd be happy to help integrating this.