Added pattern matcher for backend name.
This commit is contained in:
@@ -32,6 +32,9 @@ return (function () {
|
|||||||
'api' => [
|
'api' => [
|
||||||
'prefix' => '/v1/api',
|
'prefix' => '/v1/api',
|
||||||
'key' => env('WS_API_KEY', null),
|
'key' => env('WS_API_KEY', null),
|
||||||
|
'pattern_match' => [
|
||||||
|
'backend' => '[a-zA-Z0-9_-]+',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'database' => [
|
'database' => [
|
||||||
'version' => 'v01',
|
'version' => 'v01',
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ final class Index
|
|||||||
return api_response(HTTP_STATUS::HTTP_OK, $response);
|
return api_response(HTTP_STATUS::HTTP_OK, $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Get(self::URL . '/{id:[a-zA-Z0-9_-]+}[/]', name: 'backends.view')]
|
#[Get(self::URL . '/{id:backend}[/]', name: 'backends.view')]
|
||||||
public function backendsView(iRequest $request, array $args = []): iResponse
|
public function backendsView(iRequest $request, array $args = []): iResponse
|
||||||
{
|
{
|
||||||
if (null === ($id = ag($args, 'id'))) {
|
if (null === ($id = ag($args, 'id'))) {
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ final class GenerateAccessToken
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Post(self::URL . '/{backend:\w+}[/]', name: 'backends.plex.accesstoken')]
|
#[Post(self::URL . '/{id:backend}[/]', name: 'backends.plex.accesstoken')]
|
||||||
public function gAccesstoken(iRequest $request, array $args = []): iResponse
|
public function gAccesstoken(iRequest $request, array $args = []): iResponse
|
||||||
{
|
{
|
||||||
$backend = ag($args, 'backend');
|
$backend = ag($args, 'id');
|
||||||
|
|
||||||
$data = DataUtil::fromArray($request->getParsedBody());
|
$data = DataUtil::fromArray($request->getParsedBody());
|
||||||
|
|
||||||
|
|||||||
@@ -510,6 +510,9 @@ final class Initializer
|
|||||||
private function defaultAPIServer(iRequest $realRequest): ResponseInterface
|
private function defaultAPIServer(iRequest $realRequest): ResponseInterface
|
||||||
{
|
{
|
||||||
$router = new APIRouter();
|
$router = new APIRouter();
|
||||||
|
foreach (Config::get('api.pattern_match', []) as $_key => $_value) {
|
||||||
|
$router->addPatternMatcher($_key, $_value);
|
||||||
|
}
|
||||||
$strategy = new RouterStrategy();
|
$strategy = new RouterStrategy();
|
||||||
$strategy->setContainer(Container::getContainer());
|
$strategy->setContainer(Container::getContainer());
|
||||||
$router->setStrategy($strategy);
|
$router->setStrategy($strategy);
|
||||||
|
|||||||
Reference in New Issue
Block a user