Async Transaction Middleware for FastAPI/Starlette
Project description
transaction-middleware
Async Transaction Middleware for FastAPI/Starlette.
Installation
Using pip:
pip install transaction-middleware
Using poetry
poetry add transaction-middleware
How to use it
Transaction Middleware follows the middleware protocol and, therefore, should be added as a middleware to your FastApi or Starlette application.
The steps, using FastAPI:
from fastapi import FastAPI, Depends
from starlette.requests import Request
from starlette.responses import Response
Then set the environment variables (or your .env file)
Call the method
curl -X GET http://localhost:8000/ -H "Authorization: Bearer MY_ID_TOKEN"
Middleware configuration
The middleware configuration is done by environment variables (or using and .env file if your project uses python-dotenv).
The main variables are shown in the table below:
Name | Description | Values | Default |
---|---|---|---|
TRANSACTION_MIDDLEWARE_LOG_LEVEL | Log level for the application | DEBUG, INFO, WARNING, ERROR, CRITICAL | INFO |
TRANSACTION_MIDDLEWARE_LOG_FORMAT | Log format | See python logger documentation | %(log_color)s%(levelname)-9s%(reset)s %(asctime)s %(name)s %(message)s |
TRANSACTION_MIDDLEWARE_DISABLED | Transaction middleware enabled/disabled | false, true | false |
Project details
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
Close
Hashes for transaction_middleware-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2defc8b3e0f99ab8ad1606e7cba8bdbb0184e2498324317e75005e13ff64fea9 |
|
MD5 | 8a907a7081af1e11b824fc05ba58cd84 |
|
BLAKE2b-256 | 05745cfa05b722d5566ba20a73566bc3450b791de1a3e4557bb01b624154a5f2 |
Close
Hashes for transaction_middleware-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad62d4bddad4bf6c9b4c1ae5b0ad833ee6f4cd13a0f9c31a1aad1f005458b0d9 |
|
MD5 | e43dee0533e9f096f0519aa409934422 |
|
BLAKE2b-256 | 32e6b4e2fa1bb12c7a8847f30a83faad901c9e3cde0d175547bc7b3ff3aaaa19 |