Webhook component - pass headers to webhook handler (#17091)
* Pass headers to webhook handler * Refactors webhook component to post Request object instead of data * Update webhook tests * Cleanup webhook test and fix a bug in ifttt * Address code review comments
This commit is contained in:
1 parent
0cfbb9ce91
commit
b92b24e8a4
3 files changed
+12
-16
No files matched your search
@@ -3,7 +3,6 @@
|
||||
For more details about this component, please refer to the documentation at
|
||||
https://home-assistant.io/components/webhook/
|
||||
"""
|
||||
import json
|
||||
import logging
|
||||
|
||||
from aiohttp.web import Response
|
||||
@@ -76,16 +75,8 @@ class WebhookView(HomeAssistantView):
|
||||
'Received message for unregistered webhook %s', webhook_id)
|
||||
return Response(status=200)
|
||||
|
||||
body = await request.text()
|
||||
try:
|
||||
data = json.loads(body) if body else {}
|
||||
except ValueError:
|
||||
_LOGGER.warning(
|
||||
'Received webhook %s with invalid JSON', webhook_id)
|
||||
return Response(status=200)
|
||||
|
||||
try:
|
||||
response = await handler(hass, webhook_id, data)
|
||||
response = await handler(hass, webhook_id, request)
|
||||
if response is None:
|
||||
response = Response(status=200)
|
||||
return response
|
||||
|
||||
Reference in new issue
Block a user