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

Improves route group middleware #730

Merged
merged 8 commits into from Jun 28, 2022
Merged

Improves route group middleware #730

merged 8 commits into from Jun 28, 2022

Conversation

butschster
Copy link
Member

@butschster butschster commented Jun 25, 2022

Q A
Bugfix?
Breaks BC?
New feature? ✔️

1. Improves middleware groups

With this PR for all middleware groups will register container bindings with alias middleware:<group> and Pipeline, that contains all middleware from the group.
It will allow to do something like this:

protected function middlewareGroups(): array
{
    return [
        'web' => [
            CookiesMiddleware::class,
            SessionMiddleware::class,
            CsrfMiddleware::class,
            AuthMiddleware::class,
        ],
        'admin' => [
            'middleware:web',
            new OverwriteFirewall(new Uri('/login'), 303),
        ],
    ];
}

or

$route = new Route(....);

$route->withMiddleware('middleware:web');

2. Adds a new column group to route:list command

+-------+--------+----------------------------+------------------------------+--------+
| Name: | Verbs: | Pattern:                   | Target:                      | Group: |
+-------+--------+----------------------------+------------------------------+--------+
| html  | *      | /<action>.html             | Controller\HomeController->* | web    |
|       | *      | /[<controller>[/<action>]] | Controller\*Controller->*    |        |
+-------+--------+----------------------------+------------------------------+--------+

@codecov
Copy link

codecov bot commented Jun 25, 2022

Codecov Report

Merging #730 (6b7ea8e) into 3.0 (142bd57) will increase coverage by 0.03%.
The diff coverage is 97.67%.

@@             Coverage Diff              @@
##                3.0     #730      +/-   ##
============================================
+ Coverage     82.18%   82.21%   +0.03%     
- Complexity     5192     5197       +5     
============================================
  Files           626      627       +1     
  Lines         12793    12812      +19     
============================================
+ Hits          10514    10534      +20     
+ Misses         2279     2278       -1     
Impacted Files Coverage Δ
src/Router/src/GroupRegistry.php 75.00% <ø> (+16.66%) ⬆️
src/Router/src/Router.php 95.65% <ø> (ø)
src/Router/src/PipelineFactory.php 92.30% <92.30%> (ø)
src/Framework/Bootloader/Http/RoutesBootloader.php 100.00% <100.00%> (ø)
src/Framework/Command/Router/ListCommand.php 69.56% <100.00%> (+3.43%) ⬆️
src/Router/src/RouteGroup.php 83.87% <100.00%> (ø)
src/Router/src/Traits/PipelineTrait.php 75.00% <100.00%> (-7.15%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 142bd57...6b7ea8e. Read the comment docs.

@butschster butschster merged commit dd50c18 into 3.0 Jun 28, 2022
@butschster butschster deleted the feature/middleware-groups branch June 28, 2022 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants