Utilities for the Litestar framework.
Project description
litestar-utils
Utilities for the Litestar framework
Source Code: https://github.com/Alurith/litestar-utils
Features:
This package include some utilities I generaly use in my projects:
- Timing Middleware: Basic timing for each request
Installation:
$ pip install litestar-utils
or
$ poetry add litestar-utils
Usage:
Timing Middleware:
Use the create_timing_middleware
function to create the middleware, the only required argument is emit
.
emit
must be a callable that accept 2 arguments a Request and a float
from litestar import Litestar, get
from litestar_utils import create_timing_middleware
@get("/")
async def hello_world() -> str:
return "Hello, world!"
@get("/base", exclude_timing=True)
async def base_all() -> str:
return "All your base are belong to us"
app = Litestar(
[hello_world, base_all],
middleware=[create_timing_middleware(emit=print)],
)
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
litestar_utils-0.1.1.tar.gz
(3.0 kB
view hashes)
Built Distribution
Close
Hashes for litestar_utils-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d38b9857edd234ba58b98f3c7b29fab8a1ccf2f131d9271b80178d2e6597309 |
|
MD5 | 4c3007cb018fa86923b101688d244004 |
|
BLAKE2b-256 | 0c701b58134ac3392fe40a681e01a958c6ccd6f1b4b31eb23cd941ab76a6121c |