Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support responding with 202 Accepted status #8

Open
tobyzerner opened this issue Dec 14, 2018 · 0 comments
Open

Support responding with 202 Accepted status #8

tobyzerner opened this issue Dec 14, 2018 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@tobyzerner
Copy link
Owner

tobyzerner commented Dec 14, 2018

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;
    }
}
@tobyzerner tobyzerner added the enhancement New feature or request label Dec 14, 2018
@tobyzerner tobyzerner added this to the v1.1 milestone Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant