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_HEADER | Name for the header | Any String | X-Transaction-ID |
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.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf1da9b40af6eeb5c5a7e153e288fdf092268e40c681f1def8ad7dae942fbc6a |
|
MD5 | f5782941fa5b4ee95a785452176a089d |
|
BLAKE2b-256 | d97aaf3f3789377952b09f360bcea6545caa9da8ada555acba7bc2650ae91800 |
Close
Hashes for transaction_middleware-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1628accffc29cc44c116776fd7f391c50b2152e4e57a6e5fb2d5fe854316188 |
|
MD5 | 76999d5300ae861152ff2d9b95357c19 |
|
BLAKE2b-256 | 21a78c23761f6aeeb4dbdc55603b25e083ba2e1954e738a6d22b5944a187f87e |