-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #721 from mountaindude/master
feat: Configurable headers when getting health data from Sense
- Loading branch information
Showing
4 changed files
with
51 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const globals = require('../globals'); | ||
|
||
function getServerHeaders(server) { | ||
try { | ||
const headers = {}; | ||
|
||
// Check if there are any headers for this server that should be added | ||
if (Object.prototype.hasOwnProperty.call(server, 'headers') && server.headers !== null) { | ||
// Loop over all headers defined for the current server | ||
Object.entries(server.headers).forEach(([key, value]) => { | ||
globals.logger.debug(`SERVERHEADERS: Found header: ${value}: ${value}`); | ||
|
||
headers[key] = value; | ||
}); | ||
} | ||
globals.logger.debug( | ||
`SERVERTAGS: Additional headers for server ${server.serverName}: ${JSON.stringify( | ||
headers | ||
)}` | ||
); | ||
|
||
return headers; | ||
} catch (err) { | ||
globals.logger.error(`SERVERTAGS: ${err}`); | ||
return []; | ||
} | ||
} | ||
|
||
module.exports = { | ||
getServerHeaders, | ||
}; |