[](https://travis-ci.org/cbmi/django-webhooks)
[](https://coveralls.io/r/cbmi/django-webhooks?branch=master)
## Install
```bash
# Yes.. with a two on the end
pip install django-webhooks2
```
## Setup
Add `webhooks` to `INSTALLED_APPS`:
```python
INSTALLED_APPS = (
'webhooks',
...
)
```
## Settings
- `WEBHOOK_TIMEOUT` - Seconds to wait until a request times out
- `WEBHOOK_THREADS` - Maximum number of threads to be used in a worker pool
- `WEBHOOK_USER_AGENT` - The user-agent string for POST requests. Defaults to the current site name if the Django sites apps is installed.
- `WEBHOOK_VERSION` - The webhook version. If not None, this will be added to the user-agent string, e.g. 'Webhooks/1.0'. Default is 1.0.
## Trigger Execution
1. Events are triggered using `webhooks.trigger(event, [*args, [**kwargs]])`
2. If a handler is registered for the event, the arguments are passed into the handler to generate a JSON-serializable payload.
3. All URLs registered for this event are collected and each URL receives a POST request with the JSON payload
**Notes:**
- If no URLs are registered for the event, the payload is not generated (since it would be wasted computation)
- All requests are sent in parallel using threads
- Logging is heavily use to catch any undesirable or unexpected behaviors (such as failing requests, errors or data serialization)
## Usage
```python
import webhooks
# Define and register a handler for an event
def handler():
return { ... }
webhooks.events.register('event', handler)
# Bind a URL to the event
webhooks.bind('event', 'http://example.com')
# Trigger the event. Any arguments after the event name
# will be passed into the handler to produce the data that
# will be POSTed to the bound URLs.
webhooks.trigger('event')
```
Metadata
Release files for django-webhooks2 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-webhooks2-0.1.0.tar.gz | 6.1 kB | Without provenance | Details for django-webhooks2-0.1.0.tar.gz |
Release files / django-webhooks2-0.1.0.tar.gz
| Download URL | django-webhooks2-0.1.0.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6b10aa74740ebab7af8d20dc57757f15ce5bb9923dcc4a3696f38981371fe1dd
|
|
BLAKE2b-256 checksum How to use checksums |
79b7b85368ff416ad2509f38b6b5f9ecfca8b5a751bb6e4e450b679b8d77684a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-webhooks2 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.