diff options
Diffstat (limited to 'user_guide_src/source/general/routing.rst')
-rw-r--r-- | user_guide_src/source/general/routing.rst | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst index 5520f59fe..0b91d3fa9 100644 --- a/user_guide_src/source/general/routing.rst +++ b/user_guide_src/source/general/routing.rst @@ -142,6 +142,29 @@ routing rules to process the back-references. Example:: return 'catalog/product_edit/' . strtolower($product_type) . '/' . $id; }; +Using HTTP verbs in routes +========================== + +It is possible to use HTTP verbs (request method) to define your routing rules. +This is particularly useful when building RESTful applications. You can use standard HTTP +verbs (GET, PUT, POST, DELETE, PATCH) or a custom one such (e.g. PURGE). HTTP verb rules +are case-insensitive. All you need to do is to add the verb as an array key to your route. +Example:: + + $route['products']['put'] = 'product/insert'; + +In the above example, a PUT request to URI "products" would call the ``Product::insert()`` +controller method. + +:: + + $route['products/(:num)']['DELETE'] = 'product/delete/$1'; + +A DELETE request to URL with "products" as first the segment and a number in the second will be +mapped to the ``Product::delete()`` method, passing the numeric value as the first parameter. + +Using HTTP verbs is of course, optional. + Reserved Routes =============== |