Skip to content

Support responding with 202 Accepted status #8

Open
@tobyzerner

Description

@tobyzerner

As per:
https://jsonapi.org/format/#crud-creating-responses-202
https://jsonapi.org/format/#crud-updating-responses-202
https://jsonapi.org/format/#crud-deleting-responses-202
https://jsonapi.org/recommendations/#asynchronous-processing

class PhotosResource implements Creatable
{
    public function create(object $model, Context $context)
    {
        $job = dispatch_create_job($model);

        return new Tobyz\JsonApi\Endpoint\Status\Accepted('queue-jobs', $job);
    }
}

class QueueJobsResource
{
    public function find(string $id, Context $context)
    {
        $job = find_job($id);

        if ($job->finished) {
            return new Tobyz\JsonApi\Endpoint\Status\SeeOther('photos', $job->photo);
        }

        return $job;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions