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(http): add config parameter to headers functions #7235

Closed
wants to merge 1 commit into from

Conversation

@grisendo
Copy link

@grisendo grisendo commented Apr 24, 2014

Request Type: feature

How to reproduce:

Component(s): $http

Impact:

Complexity: small

This issue is related to:

Detailed Description:

Adds 'data' parameter in $http's header property when headers defined as functions

Other Comments:

This pull request adds to $http header functions a data parameter, so headers can use object properties to be built:

Example (in a $resource) :

...
                  login: {
                    url: './api/login.json',
                    method: 'POST',
                    headers : {
                        'Authorization': function(data) {
                          return 'Basic ' + btoa(data.user + ':' + data.pass);
                        }
                    },
...
@mary-poppins
Copy link

@mary-poppins mary-poppins commented Apr 24, 2014

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#7235)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@lefos987 lefos987 added this to the Backlog milestone Apr 24, 2014
@mary-poppins
Copy link

@mary-poppins mary-poppins commented May 2, 2014

I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let us know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@grisendo grisendo added cla: no and removed cla: yes labels May 2, 2014
@mary-poppins
Copy link

@mary-poppins mary-poppins commented May 2, 2014

CLA signature verified! Thank you!

Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes).

@grisendo grisendo added cla: yes and removed cla: no labels May 2, 2014
@IgorMinar
Copy link
Member

@IgorMinar IgorMinar commented May 2, 2014

it might be better to pass in the config object since that one contains all of the information about the request. (other people might want to set a header depending on the http method or other header value)

we'll also need tests for this change.

@grisendo grisendo changed the title feat(http): add data parameter to headers functions feat(http): add config parameter to headers functions May 3, 2014
@grisendo
Copy link
Author

@grisendo grisendo commented May 3, 2014

So now the example should be:

...
                  login: {
                    url: './api/login.json',
                    method: 'POST',
                    headers : {
                        'Authorization': function(config) {
                          return 'Basic ' + btoa(config.data.user + ':' + config.data.pass);
                        }
                    },
...
@btford btford removed the gh: PR label Aug 20, 2014
@caitp caitp force-pushed the angular:master branch from 591bac5 to d713ad1 Aug 22, 2014
@pkozlowski-opensource
Copy link
Member

@pkozlowski-opensource pkozlowski-opensource commented Aug 24, 2014

@grisendo - I think that this is a reasonable request and I can see that you've already incorporated Igor's suggestion. This PR could land but it requires a bit more work before it can be merged:

  • - it doesn't merge cleanly any more, could you please rebase it on top of the current master?
  • - we need to update docs to reflect this new argument

Thnx!

@grisendo grisendo force-pushed the grisendo:data_headers branch 2 times, most recently from f47dd1b to 000e60c Aug 25, 2014
@grisendo
Copy link
Author

@grisendo grisendo commented Aug 25, 2014

Just refactored, adding documentation later

@grisendo grisendo force-pushed the grisendo:data_headers branch from 000e60c to 51ac356 Aug 26, 2014
@grisendo
Copy link
Author

@grisendo grisendo commented Aug 26, 2014

Added also documentation changes.

@grisendo grisendo force-pushed the grisendo:data_headers branch from 51ac356 to e6965a8 Aug 27, 2014
@grisendo
Copy link
Author

@grisendo grisendo commented Aug 27, 2014

Changed to 'config object' as @pkozlowski-opensource suggested and fixed a typo.

@tbosch tbosch force-pushed the angular:master branch from 6c27b89 to 271572c Aug 30, 2014
@pkozlowski-opensource

This comment has been minimized.

Copy link

@pkozlowski-opensource pkozlowski-opensource commented on src/ng/http.js in e6965a8 Sep 5, 2014

I'm not sure if 'data' is the best argument name here... What about configObj or something along those lines?

@grisendo
Copy link
Author

@grisendo grisendo commented Sep 6, 2014

What about 'requestConfig', since is the name given to 'function $http(requestConfig) {' in 'src/ng/http.js' line 619?

@tbosch tbosch force-pushed the angular:master branch from a3d7934 to 1418383 Sep 10, 2014
@petebacondarwin petebacondarwin force-pushed the angular:master branch from 02dc2aa to fd2d6c0 Sep 16, 2014
@jeffbcross jeffbcross force-pushed the angular:master branch 2 times, most recently from cad9560 to f294244 Sep 27, 2014
@btford btford force-pushed the angular:master branch from 9011a65 to 46db47b Oct 6, 2014
@jeffbcross jeffbcross force-pushed the angular:master branch 4 times, most recently from e8dc429 to e83fab9 Oct 8, 2014
@petebacondarwin petebacondarwin force-pushed the angular:master branch from 4dd5a20 to 998c61c Oct 19, 2014
@pkozlowski-opensource pkozlowski-opensource self-assigned this Nov 25, 2014
@pkozlowski-opensource pkozlowski-opensource modified the milestones: Backlog, 1.3.8 Dec 13, 2014
@btford btford modified the milestones: 1.3.8, 1.3.9 Dec 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

7 participants