egeriis / laravel-jsonapi

Make it a breeze to create a jsonapi.org compliant APIs with Laravel 5.
MIT License
146 stars 27 forks source link

Custom endpoint for handler #40

Open johannesnagl opened 9 years ago

johannesnagl commented 9 years ago

Hi,

is there any way we can add some custom endpoints to a specific handler?

I'm talking about

POST /posts/ for creating elements POST /posts/<<ID>>/duplicate for duplicating a specific element

When defining a second POST-route I always end up calling the same handlePost() method. Is there any solution for this scenario?

egeriis commented 9 years ago

Hi @johannesnagl

POST /posts is already supported. Depending on the handler method you implement, it can create 1 or more entities.

POST /posts/{id}/duplicate is not a supported method from the JSON API spec. But you could spec an extension and implement your own extension of this library to support this method.

Hope that helps you just a bit?

johannesnagl commented 9 years ago

POST /posts is already supported. Depending on the handler method you implement, it can create 1 or more entities.

I'm totally aware of this fact! creating new posts works like a charm! but we do need custom routes, as the duplicate action. I've read in the jsonapi specs that they don't have a specific recommendation for these endpoints.

But I do think that the laravel-jsonapi plugin should provide some basic steps to allow this.

egeriis commented 9 years ago

I think there's a valid point in adding the ability to make extensions to this library. I personally do not have any suggestions on how to do this at the moment, but if you have any ideas to kickstart a discussion I am very willing to take part in that +1