Add authentication configuration and allowed methods logic
This commit is contained in:
parent
cabf1f35a8
commit
70c0fb2e54
4 changed files with 349 additions and 65 deletions
38
src/Socialbox/Classes/StandardMethods/GetAllowedMethods.php
Normal file
38
src/Socialbox/Classes/StandardMethods/GetAllowedMethods.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Socialbox\Classes\StandardMethods;
|
||||
|
||||
use Socialbox\Abstracts\Method;
|
||||
use Socialbox\Enums\StandardError;
|
||||
use Socialbox\Enums\StandardMethods;
|
||||
use Socialbox\Exceptions\DatabaseOperationException;
|
||||
use Socialbox\Exceptions\StandardException;
|
||||
use Socialbox\Interfaces\SerializableInterface;
|
||||
use Socialbox\Objects\ClientRequest;
|
||||
use Socialbox\Objects\RpcRequest;
|
||||
|
||||
class GetAllowedMethods extends Method
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function execute(ClientRequest $request, RpcRequest $rpcRequest): ?SerializableInterface
|
||||
{
|
||||
$allowedMethods = [];
|
||||
|
||||
try
|
||||
{
|
||||
foreach(StandardMethods::getAllowedMethods($request) as $method)
|
||||
{
|
||||
$allowedMethods[] = $method->value;
|
||||
}
|
||||
}
|
||||
catch(DatabaseOperationException $e)
|
||||
{
|
||||
throw new StandardException('Failed to retrieve allowed methods due to an internal exception', StandardError::INTERNAL_SERVER_ERROR, $e);
|
||||
}
|
||||
|
||||
return $rpcRequest->produceResponse($allowedMethods);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue