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 support for ResponseHeaderModifier for HTTPRouteRule objects #1880

Merged
merged 73 commits into from
May 14, 2024

Conversation

salonichf5
Copy link
Contributor

@salonichf5 salonichf5 commented Apr 25, 2024

Proposed changes

Problem: Users want to add, set, and remove response headers.

Solution: Use add_header NGINX directive to support ResponseHeaderModifier.

  • If the action is set, we simply configure the add_header directive with the given value in the HTTPRoute spec.
  • If the action is remove, we configure the add_header directive with the value set to an empty string.
  • If the action is add, we create a mapping for the $http_header_name variable appending a comma at the end of any client provided headers (if present) and prepend this to the given value in the HTTPRoute spec.

Testing: Describe any testing that you did.

Please focus on (optional): If you any specific areas where you would like reviewers to focus their attention or provide
specific feedback, add them here.

Closes #1397

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.

Introduces support for the HTTP filter `ResponseHeaderModifier`, enabling the modification of response headers within HTTPRoutes.

@github-actions github-actions bot added documentation Improvements or additions to documentation enhancement New feature or request labels Apr 25, 2024
Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.83%. Comparing base (0098b07) to head (987a368).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1880      +/-   ##
==========================================
+ Coverage   86.71%   86.83%   +0.11%     
==========================================
  Files          88       88              
  Lines        5971     6025      +54     
  Branches       50       50              
==========================================
+ Hits         5178     5232      +54     
  Misses        741      741              
  Partials       52       52              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@salonichf5 salonichf5 changed the title Feat/response header Add support for ResponseHeaderModifier for HTTPRouteRule objects Apr 25, 2024
@salonichf5 salonichf5 self-assigned this Apr 25, 2024
@salonichf5
Copy link
Contributor Author

Kevin's PR - #1494

@salonichf5 salonichf5 force-pushed the feat/response-header branch from b31db3f to e4f6129 Compare April 30, 2024 00:02
@salonichf5
Copy link
Contributor Author

Shouldn't we be adding the responseHeaderModifier validation here ? @kate-osborn

@salonichf5 salonichf5 force-pushed the feat/response-header branch from e4f6129 to 801ac2d Compare April 30, 2024 21:09
@kate-osborn
Copy link
Contributor

kate-osborn commented May 1, 2024

Shouldn't we be adding the responseHeaderModifier validation here ? @kate-osborn

@salonichf5 it looks like the intent was to make the HTTPRequestHeaderValidator more generic so it could validate both request and response headers, and then add the response header-specific validation separately in the validateFilterResponseHeaderModifier function in httproute.go.

I like your suggestion of adding a new struct to the HTTPValidator that validates response headers. I would move the functionality of validateFilterResponseHeaderModifier to that new validator.

Edit: @salonichf5 after looking through the code again, I think there will be less code duplication if we keep the approach the same. I would just rename HTTPRequestHeaderValidator to HTTPHeaderValidator and keep everything else the same.

@salonichf5 salonichf5 force-pushed the feat/response-header branch from 35fcb04 to 07d3fb2 Compare May 1, 2024 18:34
@salonichf5 salonichf5 marked this pull request as ready for review May 2, 2024 01:30
@salonichf5 salonichf5 requested review from a team as code owners May 2, 2024 01:30
examples/http-header-filter/README.md Outdated Show resolved Hide resolved
examples/http-response-header-filter/README.md Outdated Show resolved Hide resolved
examples/http-response-header-filter/headers.yaml Outdated Show resolved Hide resolved
examples/http-response-header-filter/headers.yaml Outdated Show resolved Hide resolved
examples/http-response-header-filter/README.md Outdated Show resolved Hide resolved
site/content/overview/gateway-api-compatibility.md Outdated Show resolved Hide resolved
site/content/overview/gateway-api-compatibility.md Outdated Show resolved Hide resolved
site/content/overview/gateway-api-compatibility.md Outdated Show resolved Hide resolved
site/content/overview/gateway-api-compatibility.md Outdated Show resolved Hide resolved
@salonichf5 salonichf5 requested a review from ciarams87 May 2, 2024 20:54
kevin85421 added 9 commits May 2, 2024 15:51
Problem: Users want to add, set, and remove response headers.

Solution: Use `add_header` NGINX directive to support `ResponseHeaderModifier`.
* If the action is `set`, we simply configure the `add_header` directive with the given value in the HTTPRoute spec.
* If the action is `remove`, we configure the `add_header` directive with the value set to an empty string.
* If the action is `add`, we create a mapping for the `$http_header_name` variable appending a comma at the end of any client provided headers (if present) and prepend this to the given value in the HTTPRoute spec.
@salonichf5 salonichf5 requested a review from kate-osborn May 7, 2024 22:29
@salonichf5 salonichf5 requested a review from kate-osborn May 8, 2024 18:30
@salonichf5 salonichf5 requested a review from sjberman May 9, 2024 16:22
Copy link
Contributor

@kate-osborn kate-osborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just two small changes

@salonichf5 salonichf5 requested a review from kate-osborn May 14, 2024 16:03
Copy link
Contributor

@kate-osborn kate-osborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Make sure to include @kevin85421 in the final commit message

@salonichf5 salonichf5 enabled auto-merge (squash) May 14, 2024 16:27
@salonichf5 salonichf5 merged commit 4d0a3de into nginxinc:main May 14, 2024
40 checks passed
@pleshakov pleshakov mentioned this pull request Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request release-notes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Filter: ResponseHeaderModifier
8 participants