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

Add default headers configuration. #211

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion templates/method.mustache
Expand Up @@ -13,7 +13,7 @@
}
{{#isES6}}let{{/isES6}}{{^isES6}}var{{/isES6}} deferred = {{#isNode}}Q{{/isNode}}{{^isNode}}$q{{/isNode}}.defer();
{{#isES6}}let{{/isES6}}{{^isES6}}var{{/isES6}} domain = this.domain, path = '{{&path}}';
{{#isES6}}let{{/isES6}}{{^isES6}}var{{/isES6}} body = {}, queryParameters = {}, headers = {}, form = {};
{{#isES6}}let{{/isES6}}{{^isES6}}var{{/isES6}} body = {}, queryParameters = {}, headers = this.headers, form = {};

{{#isSecure}}
headers = this.setAuthHeaders(headers);
Expand Down
2 changes: 2 additions & 0 deletions templates/node-class.mustache
Expand Up @@ -18,6 +18,8 @@
if(this.domain.length === 0) {
throw new Error('Domain parameter must be specified as a string.');
}
{{#isES6}}let{{/isES6}}{{^isES6}}var{{/isES6}} headers = (typeof options === 'object') ? options.headers : {};
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use const instead of let since you never change this variable.

Copy link
Author

Choose a reason for hiding this comment

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

You are technically right, but I decided to follow the same coding style used to define the domain attribute (line 16) in order introduce as fewer changes as possible and to establish a pattern that could be easily refactored in the future.

this.headers = headers ? headers : {};
{{#isSecure}}
{{#isSecureToken}}
this.token = (typeof options === 'object') ? (options.token ? options.token : {}) : {};
Expand Down