Skip to content

Returning no resource after POST #536

@polc

Description

@polc

Hello,

I would like to find a way to configure a Resource for returning nothing after creation (instead of created resource).

My use case :
- I have a PasswordReset resource (int id, string secret, bool used, User user)
- I have an endpoint POST /password-reset, witch create a new PasswordReset resource.
- I have an endpoint HEAD /password-reset/{id}/{secret}, who return 200 if resource exist.
- I have an endpoint POST /password-reset/{id}/{secret}, who create a new password for the user.

Obviously, I don't want the POST /password-reset to return the resource after creation. (the secret will be sent by mail to the user).

Furthermore, I don't want a GET /password-reset/{id} because it's useless.

Right now, when I call POST /password-reset, an InvalidArgumentException is throw with message "No route associated with the type "AppBundle\Entity\PasswordReset" because no GET /password-reset/{id} exist.

So I propose to add an attribute "returnResource" with default to true to the Resource annotation. And when to false, the operation return no data.

I can work on a patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions