-
Notifications
You must be signed in to change notification settings - Fork 7
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
RouteMatched Object #16
Comments
@wdalmut this is an old issue :) Idea? Target RouteMatchThe RouteMatch job will be: manage interoperability between penny and all other router.. Will be built during interface RouteMatch
{
/**
* get callable function. This is the action resolved by dispatcher
*/
public function getCallable();
/**
* set callable function.
*/
public function setCallable(callable $callable);
/**
* this is the future event name
*/
public function setName($name)
/**
* this is the future event name
*/
public function setName($name)
} The problem around this implementation is this caos and this line of code https://github.com/pennyphp/penny/blob/master/src/App.php#L106 I will use "name" to remove this 💩 |
Maybe a tiny interface? interface RouteMatchInterface
{
/** @return callable */
public function getCallable();
public function getName();
} any class class RouteMatch implements RouteMatchInterface
{
public function __construct($name, callable $dispatchable) { ... }
// Implements other methods...
} function myRouter($request) {
$matcher = //...
return $matcher->match($request); // returns a RouteMatchInterface object
} Single line router app function router($request)
{
$matcher = function($request) {
if ($request->getPath() == "/") {
return new RouteMatch("homepage", function($request, $response) {
return $response->withBody("OK");
});
}
};
return $matcher($request);
} |
Or maybe drop the interface and works with a simple array... return [
"name" => "homepage",
"callable" => function ($request) {
// ...
}
]; |
At the moment the problem is that I use DiC to build callable.. :) The callable is not ready.. I should prepare it |
Closed #91 |
Create a RouteMatch object to increase ease to change router library
The text was updated successfully, but these errors were encountered: