Skip to content

Commit

Permalink
Support multiple webhooks on a single flask app (#7)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
fspieler authored and fophillips committed Aug 14, 2017
1 parent 24b9e52 commit 605a487
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion github_webhook/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 605a487

Please sign in to comment.