Add browser XHR forwarding
This commit is contained in:
@@ -75,6 +75,16 @@ class Inspector extends Component
|
||||
{
|
||||
if (($event['endpointId'] ?? null) === $this->endpointId) {
|
||||
$this->resetPage();
|
||||
|
||||
$requestId = $event['requestId'] ?? null;
|
||||
|
||||
if (is_string($requestId) && $requestId !== '') {
|
||||
$this->dispatch(
|
||||
'xhr-request-available',
|
||||
endpointId: $this->endpointId,
|
||||
requestId: $requestId,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +110,31 @@ class Inspector extends Component
|
||||
$this->selectedRequestId = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* endpointId: string,
|
||||
* requestId: string,
|
||||
* method: string,
|
||||
* requestUri: string,
|
||||
* headers: array<string, array<int, string>|string>,
|
||||
* body: string,
|
||||
* }
|
||||
*/
|
||||
public function xhrRequestPayload(string $requestId): array
|
||||
{
|
||||
$webhookRequest = $this->endpoint()->requests()->findOrFail($requestId);
|
||||
Gate::authorize('view', $webhookRequest);
|
||||
|
||||
return [
|
||||
'endpointId' => (string) $this->endpointId,
|
||||
'requestId' => (string) $webhookRequest->getKey(),
|
||||
'method' => $webhookRequest->method,
|
||||
'requestUri' => $webhookRequest->request_uri,
|
||||
'headers' => $webhookRequest->headers ?? [],
|
||||
'body' => base64_encode((string) ($webhookRequest->body ?? '')),
|
||||
];
|
||||
}
|
||||
|
||||
public function deleteRequest(string $requestId, DeleteWebhookRequestAction $deleteWebhookRequest): void
|
||||
{
|
||||
$webhookRequest = $this->endpoint()->requests()->findOrFail($requestId);
|
||||
|
||||
Reference in New Issue
Block a user