Repository navigation
Configuration
Wes Rice edited this page Feb 11, 2016
·
10 revisions
First, ensure that craft/config/httpmessages.php exists. All routes that need to utilize Http Messages will be defined in this file.
<?php
return [
'routes' => [
'<pattern>' => [
'<http method>' => [
'<middleware handle>' => [<middleware config>]
],
],
],
];Patterns can either be static or dynamic. Static patterns will require the pattern matches the uri path verbatim. Dynamic patterns allow you to define path variables that are accessible throughout the middleware stack.
Path variables are defined by wrapping a name and an option regex pattern inside of curly braces, separated by a colon.
'/api/blog'
// Only Match: /api/blog
'/api/planet/{planet}'
// Matches: /api/planet/earth, /api/planet/mars, /api/planet/2
// Doesn't Match: /api/planet/pluto/moons
'/api/blog/{id:[0-9]+}'
// Matches: /api/blog/1, /api/blog/2
// Doesn't Match: /api/blog/my-post, /api/blog/1/commentsPortions of the path can me made optional by wrapping the optional part of the path in square brackets.
'/api/blog[/{slug}]'
// Matches: /api/blog /api/blog/my-post
// Doesn't Match: (todo)
(todo)
- [Requirements] (https://github.com/airtype/httpmessages/wiki/Requirements)
- [Installing and Updating] (https://github.com/airtype/httpmessages/wiki/Installing-and-Updating)
- [Core Concepts] (https://github.com/airtype/httpmessages/wiki/Core-Concepts)
- [PSR-7 Messages] (https://github.com/airtype/httpmessages/wiki/PSR-7-Messages)
- [Middleware] (https://github.com/airtype/httpmessages/wiki/Middleware)
- [Routing] (https://github.com/airtype/httpmessages/wiki/Routing)
- [Configuration] (https://github.com/airtype/httpmessages/wiki/Configuration)
- [Creating Middleware] (https://github.com/airtype/httpmessage/wiki/Creating-Middleware)