mercredi 25 décembre 2019

laravel how to except a certain global middleware on specific route

My api system has a query api, it should accept large query from the same ip. this api was written for this. but except this, others api should be protected.

here is part of my middleware Kernel.php

/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        // \Illuminate\Session\Middleware\AuthenticateSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
    ],

    'api' => [
        'throttle:60,1', // this is a default value
        'bindings',
        'cors',
    ],
];

but now this api:
Route::post('/trans_result', 'Result@trans_result');

I want to except throttle middleware from this api

like following fake code:
Route::post('/trans_result', 'Result@trans_result')->without('throttle'); // without is a non-existent function

Or another way, to set different rate limit for this api, that's ok



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2QftKck
via IFTTT

Aucun commentaire:

Enregistrer un commentaire