add defaults to lookup result array

This commit is contained in:
Sky Johnson 2024-09-19 12:46:46 -05:00
parent 60baec0c53
commit 1d44e8540d
2 changed files with 4 additions and 4 deletions

View File

@ -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": {

View File

@ -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