rest - Test version of web API url -
for our web api project use following url versioning system:
https://{fqdn}/{apiversion}/{apiresourcename}/{resourcepath}?{parameters}
for instance can have following:
https://myapi.mysite.com/v1/customer/2
now considering above, let want release 2 versions (live,test) customer. 1 live version (working live data) , other 1 test (working test data customer development test).
for live 1 use 1 mentioned : https://myapi.mysite.com/v1/customer/2 .
how name test version of above api? test version of api url version v1? can specify test api url?
also best practices qualified domain name of api {fqdn} when using url versioning?
there several ways this.
one way, instance, use attribute routing give different path. create separate method, give path of /vtest/customer/2
example , if users access /vtest/
version (or v2 or 3 or whatever) return test data/new version. see example in question
another way host "test data" api in different application in server , have web.config point test versions of database/source data. using iis, you'd configure 2 different applications (one test, other live) , base url differ e.g.: https://myapi.mysite.com/appname1/v1/customer/2
vs https://myapi.mysite.com/appname2/v1/customer/2
, appname live
vs test
. have @ this simple example
you host them in different servers altogether, result in {fqdn} changing between test , live versions (e.g. server.com/v1/customer/2
vs testserver.com/v1/customer/2
) - @ current job, , find effective isolates live/test data (and api versions) avoiding confusion between them.
i found this blog post detailing how namespaces
in other words there isn't 1 best/correct way want, boils down how (or company/boss/team) wants structure , control test vs live data in apis. take @ these options see 1 best in case, hope able help.
Comments
Post a Comment