This repository has been archived by the owner. It is now read-only.
Request id generation and propagation for API Star.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.bumpversion.cfg
.gitignore
LICENSE
Pipfile
Pipfile.lock
README.md
apistar_request_id.py
setup.cfg
setup.py
test_apistar_request_id.py

README.md

apistar_request_id

Request id generation and propagation for API Star.

Requirements

Installation

Use pipenv (or plain pip) to install the package:

pipenv install apistar_request_id

Usage

from apistar import App
from apistar_request_id import RequestIdHooks


routes = [
    ...
]

event_hooks = [RequestIdHooks()]

app = App(routes=routes, event_hooks=event_hooks)

All responses will automatically include an x-request-id header once you do this. The request id is inherited from the request if an x-request-id header is set, otherwise one is automatically generated from a uuid.

If you need to access the current request id from application code, you can do so via the RequestId class:

from apistar_request_id import RequestId

print(RequestId.get_request_id())

Request ids are thread-local.

License

apistar_request_id is licensed under Apache 2.0. Please see LICENSE for licensing details.