This is the official python client for Dr. Ashtetepe service.
DrHTTP let's you record two types of requests :
- Inbound : requests that are performed by clients of your server (eg. API calls from a mobile app)
- Outbound (optional) : requests that are performed by your server (eg. API call to third parties)
Note: You need to configure inbound request recording to have outbound request recording working.
Installation
-
Install package with
pip(or any compatible package manager) :pip install drhttp -
You will need a
dsn(Data source name) which can be found in your project.
Usage for Django
An integraion example is provided here
Inbound request recording
This recording is done via a wsgi middleware. You can configure it in wsgi.py:
application = ... # get your application from existing code
import drhttp
application = drhttp.WSGIMiddleware(app=application,
dsn="<insert_dsn_here")
User identification
It allows the identification of the user issuing the inbound request. You'll be able to filter requests based on this field in the web interface. drhttp will identify your user if you set the x-drhttp-user response header with the user's id as value. Fortunately, we provide you a django middleware that does it automaticaly.
MIDDLEWARE = [
...
'drhttp.DjangoUserMiddleware',
]
Device identification
Device identification works as user identification, only the header name changes (x-drhttp-device). No django middleware is provided though, it's up to you to set this header depending your device identification strategy.
Outbound request recording
Note: Outbound request recording is not available yet in the python library
Usage for Flask
An integraion example is provided here
Inbound request recording
This recording is done via a wsgi middleware. You may need to change some code in your flask app file.
The goal is to encapsulate the wsgi app in the drhttp middleware. As drhttp.WSGIMiddleware() returns a wsgi application (not a full flask application) it can't be run by flask cli, you need a wsgi application server like werkzeug/gunicorn/uwsgi.
...
app = Flask(__name__)
...
if __name__ == '__main__':
import drhttp
from werkzeug.serving import run_simple
app = drhttp.WSGIMiddleware(app=app, dsn="<insert_dsn_here>")
run_simple('0.0.0.0', 80, app)
User identification
It allows the identification of the user issuing the inbound request. You'll be able to filter requests based on this field in the web interface. drhttp will identify your user if you set the x-drhttp-user response header with the user's id as value.
Here is an example if you use Flask-HTTPAuth :
from drhttp import DRHTTP_HEADER_USER
@app.after_request
def apply_caching(response):
response.headers[DRHTTP_HEADER_USER] = auth.username()
return response
Device identification
Device identification works as user identification, only the header name changes (x-drhttp-device). It's up to you to set this header depending your device identification strategy.
Outbound request recording
Note: Outbound request recording is not available yet in the python library
Troubleshooting
Please report any issue you encounter concerning documentation or implementation. This is very much appreciated.
Metadata
Release files for drhttp 0.2.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 |
|---|---|---|---|---|
| drhttp-0.2.0.tar.gz | 5.7 kB | Without provenance | Details for drhttp-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drhttp-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for drhttp-0.2.0-py3-none-any.whl |
Total release size: 25.2 kB
Release files / drhttp-0.2.0.tar.gz
| Download URL | drhttp-0.2.0.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a3f3464931357768a978390a22751a5675f7d294593c3fe3eecdac8f17d9aea7
|
|
BLAKE2b-256 checksum How to use checksums |
9f75529ab9b2db34e35c1d418da43bd90407625fcbb60a1c3a026a37966409e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.9
|
Release files / drhttp-0.2.0-py3-none-any.whl
| Download URL | drhttp-0.2.0-py3-none-any.whl |
|---|---|
| Size | 19.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9dbb7d39d0b260c23f863a68a148fb5f6b3ee3c4ac4ebcb26a77154d047d76ff
|
|
BLAKE2b-256 checksum How to use checksums |
b39d8d153b5c5d7064be346781e97fc3091ae93e061f175fe972adf88df9b2a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.18.4 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.9
|
Security for drhttp 0.2.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.