Adding _METHOD support to routing

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1210 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2014-02-27 15:36:49 +00:00
parent 6ce3776d12
commit a50e28dc16
2 changed files with 24 additions and 6 deletions

View File

@@ -91,15 +91,21 @@ This is the routing. You need to add the routes in your index.php file with :
$route->put ("home", function () { echo "YESY"; });
$route->delete ("home", function () { echo "YESY"; });
The definition match on the HTTP method (GET,POST,PUT or DELETE).
The definition match on the HTTP method (GET,POST,PUT or DELETE). It can be
surcharged by using the _METHOD variable in POST method, with the wanted method
to use.
The routes are read sequentially. The first which match the class/method wins.
You should carrefully order the rules.
Add the debug on routing with
$route->debug=TRUE;
to help to see the matches.
We can use some variables to be passed to the called function :
$route->get ("home3/{plo}/{str}", function ($str, $plo) {echo "$str $plo";});
There is a special action named "redirect" in the "route" class. It provide the
capability to re-route the Web browser to another page. Put in action :
array ("route", "redirect", "nextPage/", FALSE),
function () use ($route) {$route->redirect("/home4", FALSE);}
If the URL match the requested search, the Web browser will load immediately a
new page named "nextPage/". The FALSE will be change in case of modular
application (see the MODULAR APPLICATION chapter)