Step 2: Understanding REST API versioning
The resource URIs contain a version token which is build as “v + integer”, for example v1 for REST API version one, v2 for version two and so on. Based on the version information provided in the resource URI the pre-routing filter extracts version information and matches against defined versioned routes.
The “ezpRestVersionedRoute” is a route wrapper around existing instance of “ezcMvcRoute” object providing multiple versions of it. Find an example of a versioned routes definition below:
new ezpRestVersionedRoute( new ezcMvcRailsRoute( '/foo', 'ezxRestController', 'foo' ), 1 )
new ezpRestVersionedRoute( new ezcMvcRailsRoute( '/foo', 'ezxRestController', 'fooBar' ), 2 )
For the first URI the
method will be executed, which is version one. For the second URI which is a version two,
will be called. Both methods can share implementation logic but differ with the output result for instance.
Geir Arne Waaler (19/01/2011 12:02 pm)
Geir Arne Waaler (21/01/2011 10:42 am)