webhook.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. use App\Module\ThirdParty\Controllers\WebhookDispatchController;
  4. /**
  5. * ThirdParty模块Webhook路由
  6. *
  7. * 路由前缀: /thirdParty/webhook
  8. * 实现路由规则:/thirdParty/webhook/{包名}/{Handler路由}
  9. */
  10. // Webhook分发路由
  11. Route::post('/{packageName}/{handlerRoute}', [WebhookDispatchController::class, 'dispatch'])
  12. ->name('webhook.dispatch')
  13. ->where('packageName', '[a-zA-Z][a-zA-Z0-9_]*')
  14. ->where('handlerRoute', '[a-zA-Z0-9_\/]+')
  15. ->middleware(['throttle:60,1']);
  16. // 支持多级Handler路由
  17. Route::post('/{packageName}/{handlerRoute}/{subRoute}', [WebhookDispatchController::class, 'dispatch'])
  18. ->name('webhook.dispatch.sub')
  19. ->where('packageName', '[a-zA-Z][a-zA-Z0-9_]*')
  20. ->where('handlerRoute', '[a-zA-Z0-9_]+')
  21. ->where('subRoute', '[a-zA-Z0-9_\/]+')
  22. ->middleware(['throttle:60,1']);
  23. // 健康检查接口
  24. Route::get('/health', [WebhookDispatchController::class, 'health'])
  25. ->name('webhook.health');
  26. // 获取已注册包列表接口
  27. Route::get('/packages', [WebhookDispatchController::class, 'packages'])
  28. ->name('webhook.packages')
  29. ->middleware(['auth:admin']);