Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

feat(http): add config parameter to headers functions #7235

Closed
wants to merge 1 commit into from

Conversation

grisendo
Copy link

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

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

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

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
Contributor

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 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);
                        }
                    },
...

@pkozlowski-opensource
Copy link
Member

@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
Copy link
Author

Just refactored, adding documentation later

@grisendo
Copy link
Author

Added also documentation changes.

@grisendo
Copy link
Author

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

@grisendo
Copy link
Author

grisendo commented Sep 6, 2014

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants