Async Transaction Middleware for FastAPI/Starlette
Project description
auth-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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffa666b25a1026cefe80f452294a9c011409916c8cc1263c89e6a6852f59fd0a |
|
MD5 | c605de12b548505f733a5b01a90e367a |
|
BLAKE2b-256 | 6f4f62f175c87aa376fc3c5863edb4af7d3afbd61b5be067da9eccd6215cb351 |
Close
Hashes for transaction_middleware-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4868517f29460a45ff65fcca340634abd91ca311ab37a836a305874ed9e113e5 |
|
MD5 | ede562cd83201c77d79bcca3addf32dc |
|
BLAKE2b-256 | e43419369ad5903feec2a216acc4e5fa3ebb7648749ac4ad3162214b3bde5023 |