Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to v2 #32

Closed
neomerx opened this issue Feb 7, 2019 · 4 comments
Closed

Update to v2 #32

neomerx opened this issue Feb 7, 2019 · 4 comments
Assignees

Comments

@neomerx
Copy link
Owner

neomerx commented Feb 7, 2019

@neomerx neomerx self-assigned this Feb 7, 2019
neomerx added a commit that referenced this issue Feb 7, 2019
neomerx added a commit that referenced this issue Feb 7, 2019
@neomerx neomerx closed this as completed in 0f03de1 Feb 7, 2019
@neomerx neomerx added fixed and removed in progress labels Feb 7, 2019
neomerx added a commit that referenced this issue Feb 8, 2019
@tuupola
Copy link

tuupola commented Feb 8, 2019

What are the BC breaks compared to 1.x?

@neomerx
Copy link
Owner Author

neomerx commented Feb 8, 2019

@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.

@neomerx
Copy link
Owner Author

neomerx commented Feb 8, 2019

@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;
}

@tuupola
Copy link

tuupola commented May 3, 2019

Quickly testing it also seems that calling ->setServerOrigin() is now mandatory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants