mercredi 4 novembre 2015

Best Practice - REST API versioning: Where and How to physically store source code

My question is not about best practices for REST API URI design.
I've decided for myself, that i'm going to use the following approach:

http://ift.tt/1Pmaxj8

I'm much more curious about how to design the actual sourcecode in advance to easily extend the API with more versions.

Let's assume we've used a classic MVC-Framework for your favorite programming language.
Our API works fine but we want to add & change functionality that is not backwards compatible. We did think about a nice URI design, but didn't think how our code should look in order to work nicely with different API versions. Crap.. What now?

Question: How should the source code for a versionable REST API look like?

Nice to have:

  1. Not mixing up the different versions
  2. Still best use of DRY
  3. Don't reinvent the wheel over again
  4. will be extended

Possible answers i can think of:

  1. Same project - different Namespaces & Subfolders

Namespace: namespace App\Http\Controllers\v1\Users;
Folder: {root_folder}\app\Http\Controllers\v1\Users\UserLoginController.php

  1. Different projects

Point http://ift.tt/1Pmaxj8 to project 1
and http://ift.tt/1kspog0 to project 2

Aucun commentaire:

Enregistrer un commentaire