How would you implement copy-paste support in a RESTful way?
Let\'s say I have book store resource. And books in every store
http://mydomain.com/rest
Copy = GET http://mydomain.com/book/1
Paste = PUT http://mydomain.com/book/2 or POST http://mydomain.com/book
I would have it so that the user executes PUT command to execute the action.
So something like a variable in the form data is contains the correct action to perform.
This is only a problem if your resources are organized to mimic a hierarchical system. Like a file system.
I prefer non-hierarchical resources. The "path" to a file would just be a property of the file. To copy-paste, there are two options.
If you really just want another "path" reference, add another entry for the "path" property. The same exact file is "in" both "folders".
If you need to new version of the file, effectively forking changes thereafter, create a new resource (different URI) with a different "path" property.
To move, just change the "path" property.
If you must insist on hierarchical, just mimic how a file system does copy-paste and move.
The copy is easy. A GET for the resource to copy.
To paste, a POST, because you are creating a new resource, a new URI.
If you need to do a move, you probably need to DELETE the old resource.
If you want, you can specify a location in the delete request, allowing the server to redirect users looking for the moved resource at its old location.