Django Middleware for optic
Project description
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_URL
environment 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.
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 optic-django-middleware-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 608cc68112a490be1e40d611b748875672b80c8598eebfa4348557bf0ed4f683 |
|
MD5 | a872c094dbbd3799d765ceabcc5c980c |
|
BLAKE2b-256 | df3526dd2ec11d509746d6d336c4a89289cac1639893e25db7aafdadba30d075 |
Hashes for optic_django_middleware-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb5248ab09a43348c7edb5624c21bebf4c9f784667c12e035eba3d9f6d913bd9 |
|
MD5 | 4e9a78abf2787e61aa3875bfbf3a358b |
|
BLAKE2b-256 | 9ca1689d8afdacb7da666fdc1328661904f5d697248ab04751288c72eb47c394 |