skip to Main Content

I am having problems with attaching a middleware to my existing routes.
Problem is with extra parameters, which cause syntax errors.

My current route:

Route::get('summary/{topicid}/{issueid}', [AppHttpControllersSummaryController::class, 'show']);

Adding the needed middleware is described in the package I am trying to use:
https://github.com/GrahamCampbell/Laravel-Throttle

I fail when I am trying to do this:

Route::get('add-to-cart/{topicid}/{issueid}', [AppHttpControllersSummaryController::class, 'show'])->middleware([GrahamCampbellThrottleHttpMiddlewareThrottleMiddleware:10,30]);

The middleware does not cause issues if I omit the :10,30 part.

TODO:
Attach the middleware with all the parameters.

2

Answers


  1. Try with that two different ways:

    Route::middleware('throttle:10,30')->group(function () {
        Route::get('summary/{topicid}/{issueid}', [AppHttpControllersSummaryController::class, 'show']);
    });
    

    OR

    Route::get('summary/{topicid}/{issueid}', [AppHttpControllersSummaryController::class, 'show'])
        ->middleware('throttle:10,30');
    
    Login or Signup to reply.
  2. Here’s how you can properly attach the ThrottleMiddleware with parameters

    use GrahamCampbellThrottleHttpMiddlewareThrottleMiddleware;

    Route::get(‘summary/{topicid}/{issueid}’, [AppHttpControllersSummaryController::class, ‘show’])
    ->middleware([ThrottleMiddleware::class . ‘:10,30’]);

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search