I’m currently working on a REST API for our application and am running into the following issue. I’m generating links as follows:
public function getLinks()
{
return [
Link::REL_SELF => Url::to(['/v1/nodes', 'id' => $this->uid], true),
];
}
As you can see I need to specify “v1” above to ensure that the link doesn’t break. But what do I do when v2 is released and this code is being executed? I would like this to upgrade automatically depending on the version that was used in the request.
What is considered good practice here. And how would I go about implementing what I want?