We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Regex style routes fail if respond() is called within a namespace. Sample code for testing purposes:
respond()
<?php include __DIR__ . '/klein/klein.php'; echo '<pre>'; respond( '/', function( $request, $response, $app ) { echo 'Hello, World.'; }); with( '/entities', function() { respond( function(){ var_dump( null ); } ); respond( '*', function(){ var_dump( '*' ); } ); respond( '/?', function(){ var_dump( '/?' ); } ); respond( '/people/[:name]', function(){ var_dump( '/people/[:name]' ); } ); respond( '@foo', function(){ var_dump( '@foo' ); } ); respond( '!@foo', function(){ var_dump( '!@foo' ); } ); respond( '!@^/foo', function(){ var_dump( '!@^/foo' ); } ); respond( '@^/foo', function(){ var_dump( '@^/foo' ); } ); respond( '@foo$', function(){ var_dump( '@foo$' ); } ); respond( '!@foo$', function(){ var_dump( '!@foo$' ); } ); respond( '@^/foo$', function(){ var_dump( '@^/foo$' ); } ); respond( '!@^/foo$', function(){ var_dump( '!@^/foo$' ); } ); respond( '@^/.*\.(json|csv)$', function(){ var_dump( '@^/.*\.(json|csv)$' ); } ); respond( '!@^/.*\.(json|csv)$', function(){ var_dump( '!@^/.*\.(json|csv)$' ); } ); }); dispatch();
In the current version of klein, most URIs (e.g. /entities/foo) will only match the catch-alls:
/entities/foo
NULL string(1) "*"
klein should be patched so that route regexes are appended to the current namespace.
The text was updated successfully, but these errors were encountered:
I've been using this extra code to debug route translations:
diff --git a/klein.php b/klein.php index 4b8f042..ec943d1 100644 --- a/klein.php +++ b/klein.php @@ -19,6 +19,8 @@ function respond($method, $route = '*', $callback = null) { $method = null; } + $orig_route = $route; + // empty route with namespace is a match-all if( $__namespace && ( null == $route || '*' == $route ) ) { $route = '@^' . $__namespace . '(/|$)'; @@ -26,6 +28,10 @@ function respond($method, $route = '*', $callback = null) { $route = $__namespace . $route; } + echo 'Original: '; var_dump( $orig_route ); + echo 'Modified: '; var_dump( $route ); + echo "----\n"; + $__routes[] = array($method, $route, $callback, $count_match); return $callback; }
Sorry, something went wrong.
No branches or pull requests
Regex style routes fail if
respond()
is called within a namespace. Sample code for testing purposes:In the current version of klein, most URIs (e.g.
/entities/foo
) will only match the catch-alls:klein should be patched so that route regexes are appended to the current namespace.
The text was updated successfully, but these errors were encountered: