How to build a route?

Good time of day.

Deployed a small project (part) in the Lumen 5.7, which performs the role of IPN/Webhooks listener. It was also decided the events of the IPN be split into groups on separate routes (PAYMENTS.CAPTURE.CREATED PAYMENTS.CAPTURE.DENIED PAYMENTS.PAYMENT.CREATED are grouped and sent to the route ipn.site.com/gateway/payments).
routes/web.php

$router->group(['prefix' => 'webhooks', 'namespace' => 'Webhooks'], function () use ($router){
 $router->post('payments', 'Payments\a dispatchercontroller@handle');
 $router->post('billing', 'Billing\a dispatchercontroller@handle');
 $router->post('identity', 'Identity\a dispatchercontroller@handle');
 $router->post('checkout', 'Checkout\a dispatchercontroller@handle');
 $router->post('customer', 'Customer\a dispatchercontroller@handle');
 $router->post('risk', 'Risk\a dispatchercontroller@handle');
 $router->post('vault', 'Vault\a dispatchercontroller@handle');
});


As You can see - each group has its own Namespace, inside of which is a dispatchercontroller, which, through the most banal of switch/case loops through the options in this group.
Dispatcher example

switch($request->get('event_type')){
 case 'CHECKOUT.ORDER.APPROVED':
 return app('App\Http\Controllers\PayPal\Webhooks\Checkout\OrderController')->approved();

 case 'CHECKOUT.ORDER.COMPLETED':
 return app('App\Http\Controllers\PayPal\Webhooks\Checkout\OrderController')->completed();

 case 'CHECKOUT.CHECKOUT.BUYER-APPROVED':
 return app('App\Http\Controllers\PayPal\Webhooks\Checkout\CheckoutController')->buyerApproved();

default:
 return app('App\Http\Controllers\CommonController')->undefinedEvent($request);
}


But my fifth point feels to use a bunch of controllers that use other controllers - g*UPE, but not a solution. I can tell you how to make this scheme better/more optimal/adequate? I would be very grateful

All beaver and key 13
April 3rd 20 at 17:28
0 answer

Find more questions by tags Lumen