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

Passing parameters to middlewares #704

Open
michaelthedev opened this issue Jan 5, 2024 · 1 comment
Open

Passing parameters to middlewares #704

michaelthedev opened this issue Jan 5, 2024 · 1 comment
Labels

Comments

@michaelthedev
Copy link

Hi
I've looked through the documentation and other issues raised here and I can't find any working way to pass parameters to middleware

I'm looking to achieve something like this

Router::group( ['middleware' => ['limiter,1,2'] ], function () {});

or this

Router::post('/path-here', [Controller::class, 'method'])
    ->addMiddleware(Limiter::class, 'paramter1', 'parameter2');

// or 
Router::post('/path-here', [Controller::class, 'method'])
    ->addMiddleware(Limiter::class, ['paramter1', 'parameter2']);

I'm available to assist on this if needed. Thanks and Happy New Year

@skipperbent
Copy link
Owner

Hi. It doesn't have a wrapper like that for the middlewares at the moment unfortunately. If you need to pass variables you will have to add a function and pass them on the request object or create alternatively create middlewares and make them extend a base one.

request()->user = User::find(1);

Happy new year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants