starlette-context
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.
Overview
starlette-context is a library that provides middleware components for the Starlette framework to maintain context data throughout the request-response cycle. It enables you to:
Access request headers and metadata from anywhere in your application
Propagate important identifiers like correlation IDs and request IDs
Enrich your logs with request context information
Store and retrieve custom data within a request’s lifecycle
Contents
- Quickstart
- Context Object
- Middleware
- Plugins
- Handling Errors
- Testing with Context
- Examples
- FastAPI Integration
- Contributing to starlette-context
- License
- Change Log
- Latest Release
- 0.5.1 - 2026-02-28
- 0.5.0 - 2026-02-28
- 0.4.0 - 2024-03-04
- 0.3.6 - 2023-02-16
- 0.3.5 - 2022-11-26
- 0.3.4 - 2022-06-22
- 0.3.3 - 2021-06-28
- 0.3.2 - 2021-04-22
- 0.3.1 - 2020-10-17
- 0.3.0 - 2020-10-10
- 0.2.3 - 2020-07-27
- 0.2.2 - 2020-04-26
- 0.2.1 - 2020-04-18
- 0.2.0 - 2020-02-21
- 0.1.6 - 2020-01-02
- 0.1.5 - 2020-01-01
- [0.1.4] - 2019-12-31