php-router icon indicating copy to clipboard operation
php-router copied to clipboard

How to use middleware separately in functions in Auto-generated Routes?

Open nabeelalihashmi opened this issue 4 years ago • 1 comments

Is is possible to use two different middlewares in same controller class while using auto generated routes?

for example, in following code, how can I use SomeMiddleware only on postMethod1 but not on getMethod1.

class SomeController extends Controller
{
    public $middlewareBefore = [
      SomeMiddleware::class
    ];

    public function getMethod1(Request $request)
    {
    }

    public function postMethod1(Request $request, Response $response)
    {
    }
}

nabeelalihashmi avatar Mar 20 '21 17:03 nabeelalihashmi

Hi @nabeelalihashmi , There is no way for that right now. Maybe we can plan somethings about that in the future.

izniburak avatar Mar 20 '21 21:03 izniburak