Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • you can do this with a software router like haproxy or nginx stackoverflow.com/questions/23259843/… Commented Apr 29, 2024 at 8:37
  • 7
    "I think there is some semantic benefit in having exactly one path for all updates of a entity, in different ways" - almost everyone else thinks the exact opposite, which is why this is hard to represent in OpenAPI. Fairly easy to implement though, you just have a meta controller that forwards to one of the two implementations. Commented Apr 29, 2024 at 9:42
  • 4
    This would be a lot more likely to use a PATCH rather than PUT. But I'm far from convinced this should use different controllers. It should probably a single controller which checks all data in the update and calls separate functions/methods/whatever to update the relevant data. Commented Apr 29, 2024 at 10:12
  • Note also that routing usually occurs way before the body is read: the body could contain a large file upload, and you don't want the router to start reading all that into memory before finally deciding (possibly without even needing the body at all) where to route the request. And controllers may handle the body via very different APIs depending on the context (read the whole body at once in some cases, use streaming in others, and the latter may be get confused if the router has already read the body or part of it). Commented Apr 29, 2024 at 10:26