Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

"Configuration Options" documentation and "headers" configuration #17

Open
wants to merge 4 commits into from

2 participants

@gabipetrovay

Hi,

We have the following requirement, to send custom headers with the API requests for two reasons:

I have also written the missing "Client Configuration Options" section in the README.md file which documents all (I guess) the options.

Could you please merge this pull request?

Thanks!

@gabipetrovay

This might be related to the other pull request: "Added Agent Support"

@IonicaBizau

I think you have to create a pull request here, instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 0 deletions.
  1. +11 −0 README.md
  2. +4 −0 index.js
View
11 README.md
@@ -23,6 +23,17 @@ You can find the docs for the API of this client at [http://ajaxorg.github.com/n
Additionally, the [official Github documentation](http://developer.github.com/)
is a very useful resource.
+## Client Configuration Options
+
+| Option | Required | Type | Description |
+| ------------- | ------------- | --------- |:----------- |
+| version | required | `string` | What Github API version to use. Currently only `3.0.0` is supported. |
+| timeout | optional | `number` | The timeout while making Github API requests. |
+| proxy | optional | `object` | Has the `host` (required) and `port` (default: `3128`) keys. The API requests will be made to this server. If the `proxy` option is missing, the following API endpoint is considered: `host`: `api.github.com`, port: depending on the `protocol`: `443` (for `https`) or `80` (for `http`). |
+| protocol | optional | `string` | What protocol to user for the API requsts. Default: `https` |
+| headers | optional | `object` | Custom headers to send in the API requests. |
+| debug | options | `boolean` | Enable or disable debug output. Default: `false` |
+
## Example
Print all followers of the user "mikedeboer" to the console.
View
4 index.js
@@ -621,6 +621,10 @@ var Client = module.exports = function(config) {
"user-agent": "NodeJS HTTP Client",
"content-length": "0"
};
+
+ for (var header in this.config.headers)
+ headers[header] = this.config.headers[header];
+
if (hasBody) {
if (format == "json")
query = JSON.stringify(query);
Something went wrong with that request. Please try again.