add defaults to lookup result array
This commit is contained in:
parent
60baec0c53
commit
1d44e8540d
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "sharkk/router",
|
||||
"description": "A simple node-based router.",
|
||||
"version": "1.1.3",
|
||||
"version": "1.1.4",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"autoload": {
|
||||
|
|
|
@ -40,7 +40,7 @@ class SegmentRouter implements Router
|
|||
if ($uri === '/') {
|
||||
return isset($node[$method])
|
||||
? ['code' => 200, 'handler' => $node[$method], 'params' => null]
|
||||
: ['code' => 405];
|
||||
: ['code' => 405, 'handler' => null, 'params' => null];
|
||||
}
|
||||
|
||||
// We'll split up the URI into segments and traverse the node tree
|
||||
|
@ -59,13 +59,13 @@ class SegmentRouter implements Router
|
|||
}
|
||||
|
||||
// if we can't find a node for this segment, return 404
|
||||
return ['code' => 404];
|
||||
return ['code' => 404, 'handler' => null, 'params' => null];
|
||||
}
|
||||
|
||||
// if we found a handler for the method, return it and any params. if not, return a 405
|
||||
return isset($node[$method])
|
||||
? ['code' => 200, 'handler' => $node[$method], 'params' => $params ?? null]
|
||||
: ['code' => 405];
|
||||
: ['code' => 405, 'handler' => null, 'params' => null];
|
||||
}
|
||||
|
||||
public function clear(): Router
|
||||
|
|
Loading…
Reference in New Issue
Block a user