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

feat: Add access to the URL and headers from plugin #89

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

jaybz
Copy link
Contributor

@jaybz jaybz commented Jan 11, 2024

I've taken the liberty of adding a few plugin methods that would allow access to the URL and headers of requests and responses. This also allows setting headers for requests via plugins but responses are read-only. This PR adds the following methods:

Request methods:

  • context.request.getHeader('<HEADER_NAME>')
  • context.request.setHeader('<HEADER_NAME>', '<HEADER_VALUE>')
  • context.request.getHeaders()
  • context.request.setHeaders(<HEADER_ARRAY>)
  • context.request.getURL()

Response methods:

  • context.response.getHeader('<HEADER_NAME>')
  • context.response.getHeaders()
  • context.response.getURL()

Copy link

netlify bot commented Jan 11, 2024

Deploy Preview for chimerical-kitsune-a0bfa0 ready!

Name Link
🔨 Latest commit bd94e53
🔍 Latest deploy log https://app.netlify.com/sites/chimerical-kitsune-a0bfa0/deploys/659fc152230cd200080f64b8
😎 Deploy Preview https://deploy-preview-89--chimerical-kitsune-a0bfa0.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@flawiddsouza
Copy link
Owner

Hi @jaybz, this is a really nice PR. Appreciate it.

image
Subtitution of environment variables doesn't make sense for response headers.

Other than that, everything looks good.

@jaybz
Copy link
Contributor Author

jaybz commented Jan 11, 2024

@flawiddsouza Looks like the test is failing due to a missing tag. Unfortunately I don't think there's a way to include tags in pull requests and I'm not sure how you'd want to proceed at this point.

edit: Hmm, seems like your comment didn't load before I posted this one. Let me fix that and update the PR.

@jaybz jaybz closed this Jan 11, 2024
@jaybz jaybz reopened this Jan 11, 2024
@flawiddsouza
Copy link
Owner

flawiddsouza commented Jan 11, 2024

@flawiddsouza Looks like the test is failing due to a missing tag. Unfortunately I don't think there's a way to include tags in pull requests and I'm not sure how you'd want to proceed at this point.

I've pushed a fix for this. Please bring this branch up to date with the latest main. Tests should pass after that.

@flawiddsouza flawiddsouza merged commit 7e5bb6a into flawiddsouza:main Jan 11, 2024
4 checks passed
@flawiddsouza
Copy link
Owner

Ignore the test for now. I'll fix it later. Thanks for the PR 🎉

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