Skip to content

Support migration of endpoints from POST to PUT #614

@mglazer

Description

@mglazer

Motivation

There are times when I want to migrate an endpoint from a POST method to a PUT method. Primarily this is brought on by placing my service behind an nginx proxy, where nginx by default will not retry POST requests. In the case that my endpoint was already idempotent, or I do some work to make my endpoint idempotent, I want to have some mechanism for safely transitioning my endpoint from POST to PUT in a reasonable way.

Currently, there are two ways I have found to achieve this:

  1. Create a legacy endpoint which sits next to new PUT endpoint, but responds to POST:
      doWork:
        http: PUT /doWork
        args:
          work:
            type: set<Long>
            param-type: body
        returns: list<Work>
      legacyDoWork:
        http: POST /doWork
        args:
          work:
            type: set<Long>
            param-type: body
        returns: list<Work>
        deprecated: POST methods are not retried by default, please use DoWork
          with PUT
  1. Handle this with "magic" at the infrastructure layer. With the undertow implementation, this just involves adding Endpoints which supports POST in addition to PUT.

I personally am in favor of option 2 because I do not want to have legacy methods sit on my public API forever, but there are others who disagree and prefer less magic. I would prefer a solution that makes everyone happy.

Proposal

I'd propose that we allow for someone to describe an endpoint something like the following:

      doWork:
        http: PUT|POST /doWork
        args:
          work:
            type: set<Long>
            param-type: body
        returns: list<Work>

Which tells clients to prefer PUT, but enables server implementations to automatically generate PUT and POST methods (where the POST implementation is identical to the PUT).

I'm also open to basically any other option here which doesn't involve API migrations requiring parallel APIs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions