Skip to content

Commit

Permalink
Add additional debugging headers
Browse files Browse the repository at this point in the history
  • Loading branch information
cundd committed Nov 11, 2019
1 parent ab26785 commit b461372
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Classes/Configuration/ConfigurationProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ public function getConfiguredResources(): array;
* @param ResourceType $resourceType
* @return ResourceConfiguration|null
*/
public function getResourceConfiguration(ResourceType $resourceType): ?\Cundd\Rest\Configuration\ResourceConfiguration;
public function getResourceConfiguration(ResourceType $resourceType): ?ResourceConfiguration;
}
8 changes: 7 additions & 1 deletion Classes/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,14 @@ private function addDebugHeaders(RestRequestInterface $request, ResponseInterfac
return $response;
}

$resourceConfiguration = $this->objectManager->getConfigurationProvider()
->getResourceConfiguration($request->getResourceType());

return $response
->withAddedHeader(Header::CUNDD_REST_RESOURCE_TYPE, (string)$request->getResourceType())
->withAddedHeader(Header::CUNDD_REST_PATH, (string)$request->getPath());
->withAddedHeader(Header::CUNDD_REST_PATH, (string)$request->getPath())
->withAddedHeader(Header::CUNDD_REST_HANDLER, $resourceConfiguration->getHandlerClass())
->withAddedHeader(Header::CUNDD_REST_DATA_PROVIDER, $resourceConfiguration->getDataProviderClass())
->withAddedHeader(Header::CUNDD_REST_ALIASES, $resourceConfiguration->getAliases());
}
}
15 changes: 15 additions & 0 deletions Classes/Http/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,19 @@ abstract class Header
* Header to send debug information about suggested routes
*/
public const CUNDD_REST_ROUTER_ALTERNATIVE_ROUTES = 'X-Cundd-Rest-Router-Alternative-Routes';

/**
* Header to send debug information about the used Handler class
*/
public const CUNDD_REST_HANDLER = 'X-Cundd-Rest-Router-Handler';

/**
* Header to send debug information about the used DataProvider class
*/
public const CUNDD_REST_DATA_PROVIDER = 'X-Cundd-Rest-Router-DataProvider';

/**
* Header to send debug information about allowed aliases
*/
public const CUNDD_REST_ALIASES = 'X-Cundd-Rest-Router-Aliases';
}

0 comments on commit b461372

Please sign in to comment.