Automatically listens and processes webhooks from third party services
Project description
Django Listener
Django Listener is a Django app that listens to and process webhooks from different providers.
Installation
Install using pip
pip install django-listener
Usage
Add 'listener'
to your INSTALLED_APPS
in settings.py.
INSTALLED_APPS = [
...
'listener',
...
]
Run migrations, python manage.py migrate listener
Go to your admin page and add a new Source
object.
- Name: Name of the source
- Slug: Slug of the source(automatically generated, but can be changed)
- Url: Url of the source
- Username: Username for basic authentication (if any)
- Password: Password for basic authentication (if any)
- Token: Token for authentication (if any)
- Token Header: Header to be used for token authentication (defaults to
HTTP_AUTHORIZATION
) - Active: Whether the source is active or not
- Unique ID Field: The field to be used as the unique identifier for the object (defaults to
id
) - HTTP Method: The HTTP method to be used for the webhook (defaults to
POST
) - Content Type: The content type to be used for the webhook (defaults to
application/json
)
Set up your webhook in the source provider to point to the url https://yourdomain.com/listener/webhooks/<source_slug>/
where <source_slug>
is the slug of the source you created.
Example: http://localhost:8080/listener/webhooks/github/
Customization (Optional)
You can customize your webhook processor by changing the LISTENER setting in your settings.py
LISTENER = {
"PROCESSOR": {
"default": "listener.processor.DefaultProcessor",
"github": "path.to.GithubProcessor",
"shopify": "path.to.ShopifyProcessor",
}
},
}
Your processor should be a function that takes in the following parameters:
- event: The event object
Your processor class must have a process
method.
For example
class GithubProcessor:
def process(self, event):
# Do something with the event
pass
Contributing
Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.
License
The MIT License (MIT). Please see License File for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_listener-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbaa34279180f192fc1bf910ae898e585760a06c83db617a550a51b1fa9ca595 |
|
MD5 | be727fcfcac6c75c78d77edbd3ae3111 |
|
BLAKE2b-256 | 9a60d590ef02cb99a71468d4c003e302bf0de0947b608fb38b9573ef6bb192cd |