TBD54566975 / tbdex

56 stars 25 forks source link

Consider changing request body structure of `PUT /exchanges/:id` #327

Closed mistermoe closed 1 month ago

mistermoe commented 2 months ago

Context

currently, the request body for "creating an exchange" (aka submitting an RFQ) looks like the following:

POST /exchanges/:id
{
  "replyTo": <optional>
  "rfq": {...}
}

and submitting a message to an exchange looks like this:

PUT /exchanges/:id

{ ...the_message }

Proposal

Proposing that we change the request body structure of PUT /exchanges/:id to be more symmetric to rfq submission. Concretely,

PUT /exchanges/:id
{
  "message": {...}
}

the way it currently is prevents us from introducing any additional fields down the line because we've effectively polluted the "root" namespace of the request body with message contents. the request body is the message

jiyoontbd commented 2 months ago

i'm thinking something like this?


// POST /exchanges
{
  "message": { ... }, // the RFQ message
  "replyTo": "example.com/reply"
}

// PUT /exchanges/:id
{
  "message": { ... } // the Order or Close message
}

not sure if this was what you were thinking of, but i like having message as top level field for all http requests for consistency, and the POST /exchanges/:id happens to have an optional replyTo top level field