2

I have a middleware added in the middleware group web which is used in my routes like

Route::group(['middleware' => ['web']], function () { // }

This web group includes multiple middleware which will be used to all routes inside the route group. I am setting these middleware like this

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\VerifyCsrfToken::class,
            \App\Http\Middleware\FeatureFlags::class
        ]
    ];

My problem here is in the FeatureFlag middleware, I want to pass a third parameter feature. Since the FeatureFlag parameter is initiated inside the web group, I have no idea how to pass the third parameter.

2
  • where do you want to pass third parameter? Commented Jun 15, 2016 at 2:34
  • i want to get the type of feature from the route which is inside the web middleware Commented Jun 15, 2016 at 3:25

1 Answer 1

1

You should be able to list your middleware in $routeMiddleware and then use it with a parameter in a middleware group

protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\VerifyCsrfToken::class,
        'flags:feature',
    ]
];

protected $routeMiddleware = [
    'flags' => \App\Http\Middleware\FeatureFlags::class,
];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.