Skip to content

add request headers to trigger functions #4012

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

Merged

Conversation

miguel-s
Copy link
Contributor

Contributing to #1461

Adds the node request headers to the request object in Parse trigger functions.

@flovilmart
Copy link
Contributor

Hi @miguel-s , I was pretty sure you would have gone down that road and that's why we didn't implement it already, the req.config should 'per-request' so I believe this would be a better place to put those headers instead of a new parameter everywhere which could be very fragile.

Could you factor the request headers in the Config, or a Config subclass so it's easier to manage in the future?

@codecov
Copy link

codecov bot commented Jul 10, 2017

Codecov Report

Merging #4012 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4012      +/-   ##
==========================================
+ Coverage   90.59%   90.59%   +<.01%     
==========================================
  Files         116      116              
  Lines        7793     7794       +1     
==========================================
+ Hits         7060     7061       +1     
  Misses        733      733
Impacted Files Coverage Δ
src/triggers.js 90.9% <ø> (+0.5%) ⬆️
src/middlewares.js 97.27% <100%> (+0.01%) ⬆️
src/RestWrite.js 93.1% <0%> (-0.39%) ⬇️
...dapters/Storage/Postgres/PostgresStorageAdapter.js 96.29% <0%> (+0.12%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0571c6f...a043aa1. Read the comment docs.

@oallouch
Copy link
Contributor

From the outside, and from someone who doesn't know the implementation, it feels weird not to have the header in req.headers.
Btw, I just needed this feature to check that a Job is called by Google App Engine's cron.yaml using the "X-Appengine-Cron" header.
Thx a lot, @miguel-s !

@flovilmart
Copy link
Contributor

@oallouch, this is already implemented in functions and jobs. Here it’s for the hooks

@oallouch
Copy link
Contributor

Ah ok. Great. Just asking, do you plan to update the docs for things like this (like afterFind in the Guide and before/afterFind in the JS SDK API ref, for instance) ?

@flovilmart
Copy link
Contributor

flovilmart commented Jul 10, 2017 via email

@miguel-s
Copy link
Contributor Author

@flovilmart just to make sure I understood you correctly, I could add the headers to the config object in the handleParseHeaders function in middlewares.js, would this be an acceptable solution?

@flovilmart
Copy link
Contributor

@miguel-s that would be better as I believe we create a new Config for each request

@oallouch
Copy link
Contributor

I knew you would say that !
I'll try.

@miguel-s
Copy link
Contributor Author

@flovilmart let me know what you think of the new approach

Copy link
Contributor

@flovilmart flovilmart left a comment

Choose a reason for hiding this comment

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

I like it, less intrusive, we'll refactor the Config at one point to be more practical :)

@flovilmart flovilmart merged commit 3c79cae into parse-community:master Jul 14, 2017
@montymxb
Copy link
Contributor

Now that this is merged in we can go ahead and close out #1461 ?

@flovilmart
Copy link
Contributor

flovilmart commented Jul 24, 2017 via email

@miguel-s miguel-s deleted the add-request-headers-triggers branch September 15, 2017 13:55
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.

4 participants