From 6f487355c21af77a22dde72beb0fced83a4a5e39 Mon Sep 17 00:00:00 2001 From: Fred Spieler Date: Mon, 14 Aug 2017 12:34:52 -0400 Subject: [PATCH] Support multiple webhooks on a single flask app When `endpoint` argument is not passed to `app.add_url_rule`, flask uses `view_func.__name__` to uniquely identify callbacks. This results in all callbacks having the same "unique" idenfitier: `_postreceive`. An easy fix is to explicitly pass in an endpoint name, which can be identical to rule name. Signed-Off-By: Frederic Spieler --- github_webhook/webhook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github_webhook/webhook.py b/github_webhook/webhook.py index 4005beb..6486566 100644 --- a/github_webhook/webhook.py +++ b/github_webhook/webhook.py @@ -17,7 +17,7 @@ class Webhook(object): """ def __init__(self, app, endpoint='/postreceive', secret=None): - app.add_url_rule(endpoint, view_func=self._postreceive, + app.add_url_rule(rule=endpoint, endpoint=endpoint, view_func=self._postreceive, methods=['POST']) self._hooks = collections.defaultdict(list)