From 72521f1376a4d31429f82b1c964b82547ee6671b Mon Sep 17 00:00:00 2001 From: Boss Date: Wed, 5 Apr 2023 15:41:37 +0200 Subject: [PATCH] update documentation Add support for custom setnotfound routing and group middleware. --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1220e4e..75a569b 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,15 @@ $router->group('/articles', function() use ($router) { }); ``` - +### `Setnotfound` route +You can set your custom notfound output +```php +$router->set404('**',function(){ + header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); + print('Not Found : ' . http_response_code()); + exit; +}); +``` ### `Class#Method` calls @@ -250,7 +258,21 @@ $router->get('/admin/:id', function($id) { print_r("Last middleware before Route function"); }); ``` - +Groupe route middleware, you should set the `pattern` and the `middleware` in order to make it work. +```php +$router->group([ +'pattern'=>'/admin/:id', +'middleware'=> function($id){ + print_r("Groupe middleware"); +} +], function($id) { + echo "admin id is:".$id; +})->middleware(function($id){ + print_r("First middleware"); +})->middleware(function($id){ + print_r("Last middleware before Route function"); +}); +``` ### Overriding the request method Use `X-HTTP-Method-Override` to override the HTTP Request Method. Only works when the original Request Method is `POST`. Allowed values for `X-HTTP-Method-Override` are `PUT`, `DELETE`, or `PATCH`.