Symfony routing with an API Web Service

Posted by fesja on Stack Overflow See other posts from Stack Overflow or by fesja
Published on 2010-03-18T15:50:20Z Indexed on 2010/03/18 15:51 UTC
Read the original article Hit count: 381

Filed under:
|
|
|

Hi,

I'm finishing the API of our web service. Now I'm thinking on how to make the route changes, so if we decide to make a new version we don't break the first API.

right now:

url: /api/:action
param: { module: api, action: :action }
requirements:
  sf_format: (?:xml|json)

what i've thought:

url: /api/v1/:module/:action
param: { module: api1, action: :action }
requirements:
  sf_format: (?:xml|json)

url: /api/v2/:module/:action
param: { module: api2, action: :action }
requirements:
  sf_format: (?:xml|json)

That's easy, but the perfect solution would be to have the following kind of route

# Automatically redirects to one module or another
url: /api/v:version/:module/:action
param: { module: api:version, action: :action }
requirements:
  sf_format: (?:xml|json)

any ideas on how to do it? what do you recommend us to do?

thanks!

© Stack Overflow or respective owner

Related posts about symfony

Related posts about routing