Skip to content
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

Filter on route group only attach / #1247

Closed
uno-de-piera opened this issue Sep 27, 2018 · 1 comment
Closed

Filter on route group only attach / #1247

uno-de-piera opened this issue Sep 27, 2018 · 1 comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them waiting for info Issues or pull requests that need further clarification from the author
Milestone

Comments

@uno-de-piera
Copy link

uno-de-piera commented Sep 27, 2018

Hi CodeIgniter team:

The filter api-auth only works with GET request on base path:

// Routes.php
$routes->group(
    'api',
    ['namespace' => 'App\Controllers\Api', 'filter' => 'api-auth'],
    function(\CodeIgniter\Router\RouteCollection $routes) {
        $routes->resource('posts', [
            'controller' =>'PostController',
        ]);
    }
);

| api/posts | get | \App\Controllers\Api\PostController::index works
| api/posts/new | get | \App\Controllers\Api\PostController::new doesn't work
| api/posts/(.)/edit | get | \App\Controllers\Api\PostController::edit/$1 doesn't work
| api/posts/(.
) | get | \App\Controllers\Api\PostController::show/$1 doesn't work
| api/posts | post | \App\Controllers\Api\PostController::create doesn't work
| api/posts/(.) | put | \App\Controllers\Api\PostController::update/$1 doesn't work
| api/posts/(.
) | delete | \App\Controllers\Api\PostController::delete/$1 doesn't work

I'm reviewing and I see that it works in the following way:

// Routes.php
$routes->group(
    'api',
    ['namespace' => 'App\Controllers\Api'],
    function(\CodeIgniter\Router\RouteCollection $routes) {
        $routes->get('courses/(:num)', 'CourseController::show/$1');
        $routes->resource('courses', [
            'controller' =>'CourseController',
        ]);
    }
);

// Filters.php
public $filters = [
    'api-auth' => ['before' => ['api*']]
];
@uno-de-piera uno-de-piera changed the title Route group with filter only attach / Filter on route group only attach / Sep 27, 2018
@jim-parry jim-parry added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 19, 2018
@jim-parry jim-parry added this to the 4.0.0-alpha milestone Oct 19, 2018
@jim-parry
Copy link
Contributor

PR1355 may have solved this. Can you test?

@jim-parry jim-parry added the waiting for info Issues or pull requests that need further clarification from the author label Nov 1, 2018
@jim-parry jim-parry modified the milestones: 4.0.0-alpha, 4.0.0 Nov 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them waiting for info Issues or pull requests that need further clarification from the author
Projects
None yet
Development

No branches or pull requests

2 participants