From fddf2006e4ed4eb708e16a8c4ba8a8a78feb054b Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 31 Jan 2021 00:01:58 +0100 Subject: [PATCH] Added headers argument to webhook event --- platypush/backend/http/app/routes/hook.py | 1 + platypush/message/event/http/hook.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/platypush/backend/http/app/routes/hook.py b/platypush/backend/http/app/routes/hook.py index 871d2a997..dcc385cc7 100644 --- a/platypush/backend/http/app/routes/hook.py +++ b/platypush/backend/http/app/routes/hook.py @@ -26,6 +26,7 @@ def _hook(hook_name): 'method': request.method, 'args': dict(request.args or {}), 'data': request.data.decode(), + 'headers': request.headers, } if event_args['data']: diff --git a/platypush/message/event/http/hook.py b/platypush/message/event/http/hook.py index 1b843067a..b423e844f 100644 --- a/platypush/message/event/http/hook.py +++ b/platypush/message/event/http/hook.py @@ -5,7 +5,7 @@ class WebhookEvent(Event): Event triggered when a custom webhook is called. """ - def __init__(self, hook, method, data=None, args=None, *argv, **kwargs): + def __init__(self, *argv, hook, method, data=None, args=None, headers=None, **kwargs): """ :param hook: Name of the invoked web hook, from http://host:port/hook/ :type hook: str @@ -18,10 +18,13 @@ class WebhookEvent(Event): :param args: Extra query string arguments :type args: dict + + :param headers: Request headers + :type args: dict """ - super().__init__(hook=hook, method=method, data=data, args=args or {}, *argv, **kwargs) + super().__init__(hook=hook, method=method, data=data, args=args or {}, + headers=headers or {}, *argv, **kwargs) # vim:sw=4:ts=4:et: -