News for hackers. Stuff that matters.
Re:A set of best practices for JavaScript projects by HatchedLake721 on Wednesday July 05, 2017 @12:37PM (#14703882)
Do both together.

Use GET/POST/PATCH/DELETE for the simple CRUD on the resource.

Then, put your actions under POST /resource/{id}/actions/{action}, e.g. `/repositories/1/actions/archive`, `/users/1/actions/ban`, `/customers/1/actions/credit-score-with-bank-of-xyz`, etc

Re:A set of best practices for JavaScript projects by urethrafranklin on Wednesday July 05, 2017 @01:18PM (#14704292)
I find the "/actions" slug a bit goofy and unnecessary. Why not just put it at e.g. "/repositories/1/archive"? Additionally, why not maintain restful semantics by using PUT (or more likely, PATCH) instead of POST (which implies creating a new resource)? And "/customers/1/actions/credit-score-with-bank-of-xyz" sounds a lot like a GET request.
Re:A set of best practices for JavaScript projects by HatchedLake721 on Wednesday July 05, 2017 @04:51PM (#14705996)
Because there could be related resources, e.g. "/repositories/1/users", or "/users/1/comments".

I agree it's not necessary, but having /actions just makes it more clear. For example:

"/repositories/1/bans" shows me all bans

"/repositories/1/ban" ban action

I know it's a bad example, but you could end up with other similar related resource and action names that could increase chances of silly mistakes.

Re:A set of best practices for JavaScript projects by denisw on Wednesday July 05, 2017 @02:05PM (#14704771)
I agree about /actions, it is unnecessary. However, for these kinds of "action resources", POST is definitely the best-matching request method. It does not mean "create a resource" (although this is one case it is often used for), but "process this request in your custom resource-specific way". The HTTP RFC formulates it like this [1]:

> The POST method requests that the target resource process the representation enclosed in the request according to the resource's own specific semantics.

Given that what an action resource does is, by definition, resource-specific, POST fits perfectly.

[1]: https://tools.ietf.org/html/rfc7231#section-4.3.3

Re:A set of best practices for JavaScript projects by always_good on Wednesday July 05, 2017 @01:09PM (#14704196)
I don't see why you'd want the /actions/ segment at all.

That's like using a /resources/ prefix at the start of every endpoint.