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
File details
Details for the file django-listener-0.1.tar.gz
.
File metadata
- Download URL: django-listener-0.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.2.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 603e0a1f22208d88fbd92be880c1f3336d4a444edbf5a2b0e0a219f3c8a909e0 |
|
MD5 | 2648c003cfb97bf76aadd7ae675a8d9c |
|
BLAKE2b-256 | ae8d3988c436ea9394ef6c891f71d3a1d7ca163dbc88bdf8f003136492a6fdca |
File details
Details for the file django_listener-0.1-py3-none-any.whl
.
File metadata
- Download URL: django_listener-0.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.2.0 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbaa34279180f192fc1bf910ae898e585760a06c83db617a550a51b1fa9ca595 |
|
MD5 | be727fcfcac6c75c78d77edbd3ae3111 |
|
BLAKE2b-256 | 9a60d590ef02cb99a71468d4c003e302bf0de0947b608fb38b9573ef6bb192cd |