-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
163 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buggregator\Trap\Sender\Websocket\RPC; | ||
|
||
use JsonSerializable; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class Response implements JsonSerializable | ||
{ | ||
public function __construct( | ||
public readonly string|int $id, | ||
public ?Rpc $rpc = null, | ||
public ?Connect $connect = null, | ||
) { | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
$data = ['id' => $this->id]; | ||
|
||
$this->rpc and $data['rpc'] = $this->rpc; | ||
$this->connect and $data['connect'] = $this->connect; | ||
|
||
return $data; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buggregator\Trap\Sender\Websocket\RPC; | ||
|
||
use JsonSerializable; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class Rpc implements JsonSerializable | ||
{ | ||
public function __construct( | ||
public readonly mixed $data, | ||
) { | ||
} | ||
|
||
public function jsonSerialize(): array | ||
{ | ||
return [ | ||
'data' => $this->data, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Buggregator\Trap\Sender\Websocket; | ||
|
||
use Buggregator\Trap\Handler\Router\Attribute\RegexpRoute; | ||
use Buggregator\Trap\Handler\Router\Attribute\StaticRoute; | ||
use Buggregator\Trap\Handler\Router\Method; | ||
use Buggregator\Trap\Logger; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class Service | ||
{ | ||
public function __construct( | ||
private readonly Logger $logger, | ||
private readonly EventsStorage $eventsStorage, | ||
) { | ||
} | ||
|
||
#[RegexpRoute(Method::Delete, '#^/api/events/(?<uuid>[a-f0-9-]++)#i')] | ||
public function eventDelete(string $uuid): bool | ||
{ | ||
$this->eventsStorage->delete($uuid); | ||
return true; | ||
} | ||
|
||
#[StaticRoute(Method::Delete, 'api/events')] | ||
public function eventsDelete(): bool | ||
{ | ||
$this->eventsStorage->clear(); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters