Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update documentation #19

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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`.
Expand Down