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

Add optional cache headers for components (#325) #326

Merged

Conversation

i-b-dimitrov
Copy link
Contributor

  • Added a function setHeader(name, value) to the context object that we pass to the component data function.

  • Subsequently these headers (if added) will be set in the response data for the returned component JSON as well as normal HTTP response headers (component.js)

  • Added a mock component (response-headers-component) and a test to cover the new functionality

* Added a function setHeader(name, value) to the context object that we pass to the component data function.

* Subsequently these headers (if added) will be set in the response data in the returned component JSON as well as response headers (component.js)

* Added a mock component (response-headers-component) and a test to cover the new functionality
@matteofigus
Copy link
Member

Awesome stuff @ivan-dimitrov-skyscanner, thanks for the PR!

@matteofigus matteofigus merged commit cc2fdff into opencomponents:master Dec 2, 2016
i-b-dimitrov added a commit to i-b-dimitrov/oc that referenced this pull request Dec 9, 2016
The problem was introduced with opencomponents#326 -
In get-component.js the declaration of responseHeaders var happens in a more
global scope than it should be. For this reason every invocation of renderer
function sees the changes in the headers made by previously requested
components.
The fix is to just move the declaration one scope inner.

- Added a unit test to validate the fix - it tries to load two components
subsequently. The first one does provide custom headers while the second
one - don't. Then we check and expect to see there are no custom headers
in the result for the second one.
i-b-dimitrov added a commit to i-b-dimitrov/oc that referenced this pull request Dec 9, 2016
The problem was introduced with opencomponents#326 -
In get-component.js the declaration of responseHeaders variable happens in a
more global scope than it should be. For this reason every invocation of
renderer function sees the changes in the headers made by previously requested
components.
The fix is to just move the declaration one scope inner.

- Added a unit test to validate the fix - it tries to load two components
subsequently. The first one does provide custom headers while the second
one - don't. Then we check and expect to see there are no custom headers
in the result for the second one.
matteofigus pushed a commit that referenced this pull request Dec 9, 2016
The problem was introduced with #326 -
In get-component.js the declaration of responseHeaders variable happens in a
more global scope than it should be. For this reason every invocation of
renderer function sees the changes in the headers made by previously requested
components.
The fix is to just move the declaration one scope inner.

- Added a unit test to validate the fix - it tries to load two components
subsequently. The first one does provide custom headers while the second
one - don't. Then we check and expect to see there are no custom headers
in the result for the second one.
@i-b-dimitrov i-b-dimitrov deleted the 325-Optional-Cache-Headers branch January 12, 2017 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants