URL Routing in seprate class

Hi Guys,

I have heard about seprate class for URL Routing in class. Can anyone help me with it?

Here is my in main config file and there are lot such Rules.


/*

 * GET api/orders/from/<:from>/count/<:count>

 * Get Infomration about Orders

 * Parameters accepted:

 *      from <optional> : Start from which order

 *      count <optional> : How many orders

 */

array(

    'api/order/list',

    'pattern' => 'api/orders',

    'verb' => 'GET'

),

array(

    'api/order/list/from/<offset>',

    'pattern' => 'api/orders/from/<offset:\w+>',

    'verb' => 'GET'

),

array(

    'api/order/list/count/<limit>',

    'pattern' => 'api/orders/count/<limit:\w+>',

    'verb' => 'GET'

),

array(

    'api/order/list/from/<offset>/count/<limit>',

    'pattern' => 'api/orders/from/<offset:\w+>/count/<limit:\w+>',

    'verb' => 'GET'

),

/*

 * GET api/orders/user/<:userid>/from/<:from>/count/<:count>

 * Get Infomration about an Order

 * Parameters accepted:

 *      userid <required> : Resource identifier for an User

 *      from <optional> : Start from which item

 *      count <optional> : How many items

 */

array(

    'api/order/list/user_id/<userid>',

    'pattern' => 'api/orders/user/<userid:\w+>',

    'verb' => 'GET'

),

array(

    'api/order/list/user_id/<userid>/from/<offset>',

    'pattern' => 'api/orders/user/<userid:\w+>/from/<offset:\w+>',

    'verb' => 'GET'

),

array(

    'api/order/list/user_id/<userid>/count/<limit>',

    'pattern' => 'api/orders/user/<userid:\w+>/count/<limit:\w+>',

    'verb' => 'GET'

),

array(

    'api/order/list/user_id/<userid>/from/<offset>/count/<limit>',

    'pattern' => 'api/orders/user/<userid:\w+>/from/<offset:\w+>/count/<limit:\w+>',

    'verb' => 'GET'

),


/*

 * GET api/orders/<:orderid>/items/from/<:offser>/count/<:limit>

 * Get Infomration about an Order

 * Parameters accepted:

 *      orderid <required> : Resource identifier for an Order

 *      from <optional> : Start from which item

 *      count <optional> : How many items

 */

array(

    'api/order/item_list/order_id/<orderid>/items',

    'pattern' => 'api/orders/<orderid:\w+>/items',

    'verb' => 'GET'

),

array(

    'api/order/item_list/order_id/<orderid>/from/<offset>',

    'pattern' => 'api/orders/<orderid:\w+>/items/from/<offset:\w+>',

    'verb' => 'GET'

),

array(

    'api/order/item_list/order_id/<orderid>/count/<limit>',

    'pattern' => 'api/orders/<orderid:\w+>/items/count/<limit:\w+>',

    'verb' => 'GET'

),

array(

    'api/order/item_list/order_id/<orderid>/from/<offset>/count/<limit>',

    'pattern' => 'api/orders/<orderid:\w+>/items/from/<offset:\w+>/count/<limit:\w+>',

    'verb' => 'GET'

),



I am asking this because, with this approach I endup writing lots of un-neccassary lines of routing. Instead If I can parse the url in array format then its just matter of array filters.