README.md in simple_controller-0.1.0 vs README.md in simple_controller-0.1.1

- old
+ new

@@ -37,6 +37,43 @@ ``` It works like a Rails Controller, but has only has the following features: - Callbacks - `params` -- `action_name` +- `action_name` + +## Router +A router is provided to decouple controller classes from identifiers. + +```ruby +class Router < SimpleController::Router +end + +# Router.instance is a singleton for ease of use +Router.instance.draw do + match "threes/multiply" + match "threes/dividing" => "threes#divide" + + controller :threes do + match :add + match subtracting: "subtract" + end + # custom syntax + controller :threes, actions: %i[power] + + namespace :some_namespace do + match :magic + end + + # no other Rails-like syntax is available +end + +Router.call("threes/multiply", number: 6) # calls ThreesController.call(:multiply, number: 6) +Router.instance.call("threes/multiply", number: 6) # same as above +``` + +To custom namespace the controller: +```ruby +Router.instance.parse_controller_name {|controller_name| "#{controller_name}_suffix_controller".classify.constantize } + +Router.call("threes/multiply", number: 6) # calls ThreesSuffixController.call(:multiply, number: 6) +``` \ No newline at end of file