Closed neomerx closed 5 years ago
What are the BC breaks compared to 1.x?
@tuupola new class for settings. Also strong typing everywhere which might require method signature updates.
I've already migrated one of the projects and only settings
part needed updates. Overall it was rather easy. BTW settings now support caching.
@tuupola For you, I think, it will only be needed to change buildSettings
to something like
private function buildSettings(ServerRequestInterface $request, ResponseInterface $response): AnalysisStrategyInterface
{
$cacheIsAvailable = ...;
if ($cacheIsAvailable === true) {
$cachedData = $this->getCorsCachedSettings();
return (new CorsSettings())->setData($cachedData);
}
$settings = (new CorsSettings())
->setServerOrigin('https', 'api.example.com', 443)
->setPreFlightCacheMaxAge(0)
->setCredentialsSupported()
->setAllowedOrigins(['https://www.example.com', ...]) // or enableAllOriginsAllowed()
->setAllowedMethods(['GET', 'POST', 'DELETE', ...]) // or enableAllMethodsAllowed()
->setAllowedHeaders(['X-Custom-Header', ...]) // or enableAllHeadersAllowed()
->setExposedHeaders(['X-Custom-Header', ...])
->disableAddAllowedMethodsToPreFlightResponse()
->disableAddAllowedHeadersToPreFlightResponse()
->enableCheckHost();
// cache settings
$dataToCache = $settings->getData();
...
return $settings;
}
Quickly testing it also seems that calling ->setServerOrigin()
is now mandatory.