handle(); return redirect()->route('inspect.show', ['token' => $endpoint->token]); } public function receive( Request $request, string $token, CaptureWebhookRequestAction $captureWebhookRequest, ): Response|JsonResponse { $endpoint = WebhookEndpoint::findByToken($token); abort_unless($endpoint instanceof WebhookEndpoint && $endpoint->acceptsRequests(), 404); if (strlen($request->getContent()) > (int) config('webhooks.max_body_bytes', 1024 * 1024)) { return response()->json(['message' => 'The webhook request body is too large.'], 413); } $captureWebhookRequest->handle($endpoint, $request); $endpoint->refresh(); return response( $endpoint->response_body ?? '{}', $endpoint->response_status, $endpoint->response_headers ?? ['Content-Type' => 'application/json'], ); } public function destroy(string $token): RedirectResponse { $endpoint = WebhookEndpoint::findByToken($token); abort_unless($endpoint instanceof WebhookEndpoint, 404); Gate::authorize('delete', $endpoint); $endpoint->delete(); return redirect()->route('home')->with('status', 'Endpoint deleted.'); } }