Optic Django Middleware
This module is an Django middleware using optic-sdk to capture and format HTTP data to send to Optic. We have a list of middleware available for some frameworks, if we are missing the framework join our community and suggest the next framework or develop it with us.
Requirements
The module requires @useoptic/cli to be installed, instructions on installing it are available https://www.useoptic.com/docs/.
Install
pip install optic-django-middlewaree
Usage
The middleware takes a configuration object and captures traffic in the background as long as @useoptic/cli is installed.
Configuration
Environment variables can also be used to set the values
ENABLE:boolean(defaults toFALSE) Programmatically control if capturing data and sending it to OpticUPLOAD_URL:string(defaults toos.environ['OPTIC_LOGGING_URL']) The URL to Optics capture URL, if left blank it will expectOPTIC_LOGGING_URLenvironment variable set by the Optic CLICONSOLE:boolean(defaults toFALSE) Send to stdout/console for debuggingframework:string(defaults to '') Additional information to inform Optic of where it is capturing informationLOG:boolean(defaults toFALSE) Send to log fileLOG_PATH:boolean(defaults to./optic.log) Log file pathLOCAL:boolean(defaults toTRUE) Send to optic cliINTERACTION_MANAGER:string(defaults tooptic_django_middleware.manager.BasicOpticManager) Manager module to control the behaviour of capturing and sending interaction
Example
# settings.py
import os
from tempfile import mkdtemp
tempdir = mkdtemp('optic_django')
OPTIC = {
'ENABLE': True,
'LOG_PATH': os.path.join(tempdir, 'optic.log'),
'LOG': True,
'CONSOLE': False,
'LOCAL': False
}
INSTALLED_APPS += [
'optic_django_middleware',
]
To start capturing data from the SDK, run your application with
api exec "python manage.py runserver"
License
This software is licensed under the MIT license.
Metadata
Release files for optic-django-middleware 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| optic-django-middleware-0.1.2.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| optic_django_middleware-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.9 kB
Release files / optic-django-middleware-0.1.2.tar.gz
| Download URL | optic-django-middleware-0.1.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9512955846720888a1cea8f58b54e2bd6187753e5d63b5da1118763d786d978
|
|
BLAKE2b-256 checksum How to use checksums |
5fe8e6b5b37816c0fdfcfcc82cb757f3ce10d28db7c3a539cfafd2550487df38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.7 CPython/3.7.11 Linux/5.8.0-1039-azure
|
Release files / optic_django_middleware-0.1.2-py3-none-any.whl
| Download URL | optic_django_middleware-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d1b3b6b2703f51aa99b432cd76b8736ed8ea8803a43e4a0442671741a023f0e
|
|
BLAKE2b-256 checksum How to use checksums |
0561ac2866d11384edbd48d84e9ebd8861f635f190922267e592b21949caa929
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.7 CPython/3.7.11 Linux/5.8.0-1039-azure
|