Skip to content

Commit 605a487

Browse files
fspielerfophillips
authored andcommitted
Support multiple webhooks on a single flask app (#7)
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 <[email protected]>
1 parent 24b9e52 commit 605a487

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

github_webhook/webhook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Webhook(object):
1717
"""
1818

1919
def __init__(self, app, endpoint='/postreceive', secret=None):
20-
app.add_url_rule(endpoint, view_func=self._postreceive,
20+
app.add_url_rule(rule=endpoint, endpoint=endpoint, view_func=self._postreceive,
2121
methods=['POST'])
2222

2323
self._hooks = collections.defaultdict(list)

0 commit comments

Comments
 (0)