API RESTful Version
Hello,
We need to create a versioning of an existing API, so we going to set a default version (so far) for current connections to version 1
My first attempt is:
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
<Route Url="(?i)/check" Method="GET" Call="CheckApi"/>
<Route Url="(?i)/getcustomer" Method="POST" Call="GetCustomerDefault"/>
<Route Url="(?i)/revoke" Method="DELETE" Call="RevokeDefault"/>
<Route Url="(?i)/:version/getcustomer" Method="POST" Call="GetCustomer"/>
<Route Url="(?i)/:version/revoke" Method="DELETE" Call="Revoke"/>
</Routes>
}
Parameter DEFAULTVERSION = 1;
Parameter CURRENTVERSION = 2;
ClassMethod GetCustomerDefault() As %Status
{
quit ..GetCustomer(..#DEFAULTVERSION)
}
ClassMethod GetCustomer(pVersion As %Integer) As %Status
{
// This is the code for all version. Get the Id and pass into the message
........
quit $$$OK
}
Also, I have a parameter called DEFAULTVERSION with value 1
By this way, the newer calls will have the version number and response according the version of API
The URL will be:
apiserver.com/api/2/getCustomer
I'm checking if the version is less than a CURRENTVERSION, the call is fine
According to a new especification, the URL will be "api/v2/getCustomer", before it was an integer, and now will be a string.
How can I check if this parameter is well formed (v and number), then I can evaluate if the number is an valid API version?
We can change our versioning, so any suggest will be welcome