3 ms·
If you don't mind me asking how exactly to you guys process requests with a versioned API? Say I come in with a request for V2. How does that get directed to t
by malsheikh 10y ago
If you don't mind me asking how exactly to you guys process requests with a versioned API?
Say I come in with a request for V2. How does that get directed to the V2 code path? What about services that are identical in V1 and V2. Do you have 2 copies of the same logic? Sorry for the naive question but API versioning is something that has been on my mind recently.
- brandur 10y ago> If you don't mind me asking how exactly to you guys process requests with a versioned API? This information has been talked about publicly before, so I don't mind explaining at all. For the most part, the core API endpoint logic is all coupled to just the latest version. For each substantial API change in each new API version, logic is encapsulated into what we call a "compatibility gate". Before responding, a merchant's current version is looked up, and the response is passed back through a compatibility layer that applies changes for each gate until it's been walked all the way back to the target version, then the response is sent back. I'm glossing over a few details here of course — versioning can affect request parameters and even core logic in many places, so some gates need to be embedded throughout core code. We try to keep that as clean as we can.