问题描述:

I am wondering what the best way of creating a resource from multiple different sources could look like. Here i a simplified scenario:

Imagine a resource of type boilerplate can be created in multiple ways: cloning an existing one or uploading a pre-defined one.

Variation 1: Query Params

POST /api/v1/boilerplates //=> Normal way to create a new one by posting JSON

POST /api/v1/boilerplates?cloneId="IdToCloneFrom" //=> Second way by cloning

Variation 2: Actions

POST /api/v1/boilerplates //=> Normal way to create a new one by posting JSON

POST /api/v1/boilerplates/action/clone //=> Second way by cloning

I tend towards the second one as it is more descriptive for the user of the API, but I am not sure. Any other ways I am missing?

相关阅读:
Top