Webhooks are handled in a non-compatible way with the other APIs
166377
def perform_webhook
      http_request.body  = {'text'  => params[:text]}.to_json.to_s
      http_request.query = {'token' => params[:token]}
      HTTPI.post(http_request)
    end
280155
def update!
      client.put("/webhooks/#{id}", {
        description: description,
        idModel: id_model,
        callbackURL: callback_url,
        active: active
      })
    end
728723
function getHook(className, hookType) {
  if (hooks[className] && hooks[className][hookType]) {
    return hooks[className][hookType];
  }
  return undefined;
}
512051
def set_webhook_handler(self, scope, callback):
        
        scope = scope.lower()

        if scope == 'after_send':
            self._after_send = callback
            return

        if scope not in Page.WEBHOOK_ENDPOINTS:
            raise ValueError("The 'scope' argument must be one of {}.".format(Page.WEBHOOK_ENDPOINTS))

        self._webhook_handlers[scope] = callback
16819
function _postHandlers() {
  // any authentication checks first
  if(config.authentication.enabled) {
    logger.info(pkgname + "  authentication to API's enabled");
    app.all(config.api.path, function(req, res, next) {
      if(config.authentication.ignores && req.params) {
        // check if the params is in ignores list
        var matches = _.filter(req.params, function(param) {
          return _.find(config.authentication.ignores, function(ignore) {
            return param.indexOf(ignore)==0;
          });
        });
        if(matches && matches.length>0) {
          logger.debug(pkgname+"ignored auth for param:" + matches);
          return next();
        }
      }
      if(req.loggedIn) {
        return next();  // auth success go to next
      } else {
        return next(error(401, 'unauthorized access'));
      }
    });
  }

  // install api checks
  if(config.api.keycheck) {
    logger.info(pkgname + "  keycheck to API's enabled");
    // here we validate the API key 
    app.all(config.api.path, function(req, res, next){
      var key = req.query[config.api.KEYNAME] || req.body[config.api.KEYNAME];
 
      // key isnt present
      if (!key) return next(error(400, 'api key required'));
 
      // key is invalid
      if (!~config.api.keys.indexOf(key)) return next(error(401, 'invalid api key'));
 
      // all good, store req.key for route access
      req.key = key;
      next();
    });
  }

  // jsonp support for delete, put & post (partial post)
  if(config.server.jsonp) {
    logger.info(pkgname + "  jsonp support on api's enabled");
    // check if callback is there along with method
    app.all(config.api.path, function(req, res, next) {
      if(req.query && req.query['callback'] && req.query['_method']) {
        // lets rewrite the method, especially PUT/DELETE/POST
        req.method=req.query['_method'];
        logger.debug(pkgname + "jsonp request converted:"+req.query);
      }
      next();
    });
  }

  var api = {
    index: function(req,res) {
      res.json({app:config.app.title, version:config.app.version});
    }
  };
  global.apiresource = app.resource('api', api);
  logger.info(pkgname + "  api handler added");
  logger.debug(pkgname + "init complete");
}
533095
function nextPostHook(res) {
                    response = checkResponse(res, response);

                    if (currentPost + 1 < totalPost && self.__hooksEnabled !== false) {
                        currentPost += 1;

                        // Reference to current post hook
                        const currPost = posts[currentPost];
                        const hookMethod = currPost.displayName || currPost.name;
                        scope = getScope(self, name, res, hookMethod, 'post');

                        // Recursively call all the "post" hooks
                        return currPost.call(scope, response).then(nextPostHook, postHookErrorHandler);
                    }

                    /**
                     * All "post" hook process done.
                     * If the response has an "__override" property it will be our response
                     */
                    if (is.object(response) && {}.hasOwnProperty.call(response, '__override')) {
                        response = response.__override;
                    }

                    return resolveFn(response);
                }
919222
def send_msg_to_webhook(self, json_payload, log_msg):
        
        if SILENCE_OVERRIDE:  # pragma: no cover
            return

        payload = {
            'text': log_msg,
            'attachments':[json_payload]
        }
        header = {
            'Content-Type':'application/json'
        }

        try:
            request = requests.post(
                self.webhook_url,
                headers=header,
                json=payload
            )
            request.raise_for_status()
        except Exception as error_msg:  #pragma: no cover
            warning_msg = (
                'EXCEPTION: UNABLE TO COMMIT LOG MESSAGE' +
                '\n\texception={0}'.format(repr(error_msg)) +
                '\n\tmessage={0}'.format(log_msg)
            )
            warnings.warn(
                warning_msg,
                exceptions.WebhookFailedEmitWarning
            )
798159
def start_webhook(dispatcher, webhook_path, *, loop=None, skip_updates=None,
                  on_startup=None, on_shutdown=None, check_ip=False, retry_after=None, route_name=DEFAULT_ROUTE_NAME,
                  **kwargs):
    
    executor = set_webhook(dispatcher=dispatcher,
                           webhook_path=webhook_path,
                           loop=loop,
                           skip_updates=skip_updates,
                           on_startup=on_startup,
                           on_shutdown=on_shutdown,
                           check_ip=check_ip,
                           retry_after=retry_after,
                           route_name=route_name)
    executor.run_app(**kwargs)
655293
function executeHooks(data, allHooks, checkHooks, creationMode) {
    var hooksToCall = creationMode ? allHooks : checkHooks;
    if (hooksToCall) {
        callHooks(data, hooksToCall);
    }
}
410125
def send_webhook(config, payload):
    
    try:
        response = requests.post(
            config['webhook_url'],
            data=json.dumps(payload, cls=ModelJSONEncoder),
            headers={config['api_key_header_name']: config['api_key']},
        )
    except Exception as e:
        logger.warning('Unable to send webhook: ({1}) {2}'.format(
            e.__class__.__name__,
            e.message,
        ))
    else:
        logger.debug('Webhook response: ({0}) {1}'.format(
            response.status_code,
            response.text,
        ))
1212975
function CruxGithookComponent(__name) {
  Githook.super_.apply(this, arguments);
  this.name = (typeof __name === 'string' ? __name : 'redis');
  this.client = {};
}
195862
function callHook(name, getArgument, handleResult, output) {
    getArgument = getArgument || defaultGetArgument;
    handleResult = handleResult || defaultHandleResult;

    var logger = output.getLogger();
    var plugins = output.getPlugins();

    logger.debug.ln('calling hook "' + name + '"');

    // Create the JS context for plugins
    var context = Api.encodeGlobal(output);

    return timing.measure(
        'call.hook.' + name,

        // Get the arguments
        Promise(getArgument(output))

        // Call the hooks in serie
        .then(function(arg) {
            return Promise.reduce(plugins, function(prev, plugin) {
                var hook = plugin.getHook(name);
                if (!hook) {
                    return prev;
                }

                return hook.call(context, prev);
            }, arg);
        })

        // Handle final result
        .then(function(result) {
            output = Api.decodeGlobal(output, context);
            return handleResult(output, result);
        })
    );
}
1014142
function RequestHooks_has(regex) {
        if (!Type.isRegExp(regex)) {
            throw new error.DataError({regex: regex}, "RequestHooks.has regex must be regex type");
        }
        return !!this.hooks.filter(function (item) {
            return item.key.source === regex.source;
        }).shift();
    }
126467
function patchHooks(hooks) {
  var original = {};
  var restore;

  hookTypes.map(function(key) {
    original[key] = global[key];

    global[key] = function(title, fn) {
      // Hooks accept an optional title, though they're
      // ignored here for simplicity
      if (!fn) fn = title;
      hooks[key] = createWrapper(fn);
    };
  });

  restore = function() {
    hookTypes.forEach(function(key) {
      global[key] = original[key];
    });
  };

  return restore;
}
831112
public function triggerHook()
    {
        $hookUrl = $this->getLink('#hook');
        $options = [];

        // The API needs us to send an empty JSON object.
        $options['json'] = new \stdClass();

        // Switch off authentication for this request (none is required).
        $options['auth'] = null;

        $this->sendRequest($hookUrl, 'post', $options);
    }
604846
def call_webhook(event, webhook, payload):
    """"""
    started_at = time()

    request = _build_request_for_calling_webhook(event, webhook, payload)

    logger.info('REQUEST %(uuid)s %(method)s %(url)s %(payload)s' % dict(
        uuid=str(event['uuid']),
        url=request['url'],
        method=request['method'],
        payload=payload,
    ))

    try:
        content = dispatch_webhook_request(**request)

        logger.debug('RESPONSE %(uuid)s %(method)s %(url)s %(data)s' % dict(
            uuid=str(event['uuid']),
            url=request['url'],
            method=request['method'],
            data=content,
        ))

        data = dict(
            parent=str(event['uuid']),
            content=content,
            started_at=started_at,
            ended_at=time()
        )
    except (FailureWebhookError, ConnectionError) as exception:
        if sentry.client:
            http_context = raven_context(**request)
            sentry.captureException(data={'request': http_context})

        logger.error('RESPONSE %(uuid)s %(method)s %(url)s %(error)s' % dict(
            uuid=str(event['uuid']),
            method=request['method'],
            url=request['url'],
            error=exception.message,))

        data = dict(
            parent=str(event['uuid']),
            error=exception.message,
            started_at=started_at,
            ended_at=time(),
        )

    webhook_ran.send(None, data=data)

    return data
277845
def post(self, data):
        
        if not self.url:
            raise Error('URL for incoming webhook is undefined')

        return requests.post(self.url, data=json.dumps(data),
                             timeout=self.timeout, proxies=self.proxies)