cloudfoundry-attic / cf-abacus

CF usage metering and aggregation
Apache License 2.0
98 stars 86 forks source link

Add custom header in the batch request #1097

Open wanglw opened 6 years ago

cfdreddbot commented 6 years ago

Hey wanglw!

Thanks for submitting this pull request!

All pull request submitters and commit authors must have a Contributor License Agreement (CLA) on-file with us. Please have everyone sign the appropriate CLA (individual or corporate), and send to: contributors@cloudfoundry.org.

When sending a signed CLA please provide your github username in case of an individual CLA or the list of github usernames that can make pull requests on behalf of your organization.

The following github user @wanglw has not signed the appropriate CLA.

If you are confident that everyone listed is covered under a Corporate CLA, please make sure everyone has publicized their membership in the appropriate Github Org, per these instructions.

Once everyone has publicized their membership, one of the owners of this repository can close and reopen this pull request, and dreddbot will take another look.

cf-gitbot commented 6 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/161644021

The labels on this github issue will be updated when the story is started.

codecov[bot] commented 6 years ago

Codecov Report

Merging #1097 into master will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1097   +/-   ##
=======================================
  Coverage   95.21%   95.21%           
=======================================
  Files         126      126           
  Lines        3509     3509           
=======================================
  Hits         3341     3341           
  Misses        168      168

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 a48be75...5a6b2c7. Read the comment docs.

hsiliev commented 6 years ago

Can you please point out how adding customHeader works? Is this handled by request or express module?

wanglw commented 5 years ago

@hsiliev Based on my understanding, I think it is handled by request.

Code level: In our example, we get the customHeader in our code like this:

var myHeader = req.customHeader["if-match"] ? req.customHeader["if-match"] : "";

Example: POST http://localhost:11443/batch body includes the customeHeader:

[
    {
        "method": "PUT",
        "uri": "XXXXXXXX",
        "body": {
            "test_id": "TEST",
            "state": "test"
        },
        "headers": {
            "if-match": "7-0b6a49e921a6a9214a5503e29adcc7eb"
        }
    }
]
hsiliev commented 5 years ago

I don't see customHeader in the source of request (nor in express) and that's why I asked.

In fact the docs mention only headers option (https://github.com/request/request#custom-http-headers), so I think the change should actually be:

headers: r.headers