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

4.x - MiddlewareDispatcherInterface #2817

Merged
merged 9 commits into from Aug 20, 2019

Conversation

l0gicgate
Copy link
Member

Closes #2785

This PR enables users to inject their own MiddlewareDispatcher into the App component.

The new proposed interface:

<?php
declare(strict_types=1);

namespace Slim\Interfaces;

use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;

interface MiddlewareDispatcherInterface extends RequestHandlerInterface
{
    /**
     * Add a new middleware to the stack
     *
     * Middleware are organized as a stack. That means middleware
     * that have been added before will be executed after the newly
     * added one (last in, first out).
     *
     * @param MiddlewareInterface|string|callable $middleware
     * @return self
     */
    public function add($middleware): self;

    /**
     * Add a new middleware to the stack
     *
     * Middleware are organized as a stack. That means middleware
     * that have been added before will be executed after the newly
     * added one (last in, first out).
     *
     * @param MiddlewareInterface $middleware
     * @return self
     */
    public function addMiddleware(MiddlewareInterface $middleware): self;

    /**
     * Seed the middleware stack with the inner request handler
     *
     * @param RequestHandlerInterface $kernel
     * @return void
     */
    public function seedMiddlewareStack(RequestHandlerInterface $kernel): void;
}

@l0gicgate l0gicgate added this to the 4.2.0 milestone Aug 20, 2019
@l0gicgate l0gicgate force-pushed the MiddlewareDispatcherInterface branch from 7b99abf to e41d1aa Compare August 20, 2019 16:06
@l0gicgate l0gicgate force-pushed the MiddlewareDispatcherInterface branch from e41d1aa to 8e0f835 Compare August 20, 2019 16:11
@l0gicgate l0gicgate force-pushed the MiddlewareDispatcherInterface branch from a2d911a to aed55cf Compare August 20, 2019 16:20
@coveralls
Copy link

coveralls commented Aug 20, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling e830a8c on l0gicgate:MiddlewareDispatcherInterface into 89f8076 on slimphp:4.x.

Copy link
Contributor

@adriansuter adriansuter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent.

Slim/MiddlewareDispatcher.php Show resolved Hide resolved
Slim/MiddlewareDispatcher.php Show resolved Hide resolved
tests/AppTest.php Show resolved Hide resolved
@l0gicgate l0gicgate merged commit a0435c3 into slimphp:4.x Aug 20, 2019
@l0gicgate l0gicgate deleted the MiddlewareDispatcherInterface branch August 20, 2019 18:53
@l0gicgate l0gicgate mentioned this pull request Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.x - MiddlewareDispatcherInterface
3 participants