I would first question whether '/veryimportantroute' is necessary
because that causes most of the complication. Can't the clients
explicitly call the version they're compatible with? Or can't your
view handle all request versions, either by noticing that a new
argument does or doesn't exist or has a different format, or by a
'version' argument? Or can '/veryimportantroute' simply redirect to
the latest version?
If all the views are different, you can handle this in the view
configuration, by tying route 1 to view A, route 2 to view B, and
route 3 to view B. (Or a redirect view, or do the redirect in
Apache/NGINX.)
If it's all going to a single view, then the view may need to know
whether 'v2' or 'v3' was specified. (This is equivalent to a 'version'
argument, but in the URL.) If you have a single route, then the
version can be a match variable. If you have two different routes,
then it won't be a match variable and you'll have to determine it via
some other trickery (such as a custom route predicate, or have the
view look back on the path, but both of those can be inelegant.
If you tell us some more about when/how you expect the API to change,
and whether there will be a separate view for each version or one view
for multiple versions, then we could answer it more precisely. Or if
the answer is, "I don't know and I just want to generally future-proof
the site", then the answer may be "We don't know what to do because we
don't know what kind of need will arise". If there's only one version
now, you could either put '/v1' in front of everything just in case,
or leave it out until the future reveals what you'll need. You may
find you won't need the version prefixes: the view can simply deduce
what version the client is from the arguments, and return a response
for that version. Or if a new API has actual new URLs (new views),
then they'll never be called in the old version or if they are it's an
error.
--
Mike Orr <
slugg...@gmail.com>