Commit
Make debug a prototype method. This has a couple of advantages: - It's no longer necessary for the debug code to be at a specific place in request.js, see request#1354 - It's easier for helper methods in other files to generate debug messages, see request#1360
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,9 @@ var md5 = helpers.md5 | |
, toBase64 = helpers.toBase64 | ||
|
||
|
||
function Auth () { | ||
function Auth (request) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nylen
Author
Owner
|
||
// define all public properties here | ||
this.request = request | ||
this.hasAuth = false | ||
this.sentAuth = false | ||
this.bearerToken = null | ||
|
@@ -116,7 +117,7 @@ Auth.prototype.response = function (method, path, headers) { | |
|
||
var authHeader = c.get('www-authenticate') | ||
var authVerb = authHeader && authHeader.split(' ')[0].toLowerCase() | ||
// debug('reauth', authVerb) | ||
self.request.debug('reauth', authVerb) | ||
|
||
switch (authVerb) { | ||
case 'basic': | ||
|
I think it's better to have this logic inside each module that needs it.
There is really not that much related to Request, nor to the Request's instance.
Request.debug
is a static var, soRequest.prototype.debug
is not per instance either.So if that was the only reason to pass the entire request instance here, I would suggest not to do that.