mirror of
https://github.com/yagop/node-telegram-bot-api
synced 2025-09-05 08:45:44 +00:00
[webhook] Allow passing options to HTTPS server
Feature: We shall allow passing more options to the HTTP server, in `https.createServer()`. We are using a new property, `https`, to avoid any namespace collisions with our own options. `options.key`, `options.cert` and `options.pfx` are convenient options, in that they allow the user to provide paths to the corresponding files, which are read automatically, though synchronously! Implementation: * completely backwards-compatible * all changes are being tested, except `options.pfx` References: * Pass `ca` prop to https.createServer(): https://github.com/yagop/node-telegram-bot-api/pull/17
This commit is contained in:
@@ -37,6 +37,7 @@ exports = module.exports = {
|
||||
* @param {Object} [options]
|
||||
* @param {String} [options.method=POST] Method to use
|
||||
* @param {Object} [options.message] Message to send. Default to a generic text message
|
||||
* @param {Boolean} [options.https=false] Use https
|
||||
* @return {Promise}
|
||||
*/
|
||||
sendWebHookMessage,
|
||||
@@ -136,7 +137,8 @@ function hasOpenWebHook(port, reverse) {
|
||||
function sendWebHookMessage(port, token, options = {}) {
|
||||
assert.ok(port);
|
||||
assert.ok(token);
|
||||
const url = `http://127.0.0.1:${port}/bot${token}`;
|
||||
const protocol = options.https ? 'https' : 'http';
|
||||
const url = `${protocol}://127.0.0.1:${port}/bot${token}`;
|
||||
return request({
|
||||
url,
|
||||
method: options.method || 'POST',
|
||||
|
Reference in New Issue
Block a user