Routes.json is the routes configuration file for a Sodapop application, located in the application's /conf directory. It is required to exist, but can be blank if the application wishes to use only the default routing scheme.
An example routes.json file can be seen here:
By default, Sodapop processes routes in this manner:
Routes.json provides a simple and flexible way of customizing routing behavior, using PHP's regular expression capabilities.
When a request is made, Sodapop will attempt to match the URL requested against the application's routing table. If a match is found, it will invoke the controller and action listed. The order of routes is important. As some routes contain a subset of others, it is important to list the more specific ones prior to the more general ones, as Sodapop will go with the first match when choosing route. In the example routes.json listed above:
The URL matches the second line of the routes file, so the actionVote method of the PostController controller would be invoked, and a request variable called post_slug would be set from the matching pattern.
The regular expressions used will need to be escaped to make them into valid JSON.
Please note that Sodapop's default behavior of creating request variables from parts of the request past the controller and action names (illustrated in the default URL example above) does not occur with route matches.