Closed commentator8 closed 2 years ago
I started adding that in #15 a while back, then thought I'd wait until someone requested it before adding it.
What do you think about both a validator and a generator, like this?
app.add_middleware(
CorrelationIdMiddleware,
header_name='X-Request-ID',
generator=lambda: uuid4().hex,
validator=is_valid_uuid,
transformer=lambda a: a,
)
If you have time, I'd love some feedback on that PR
I didn't follow the point you wrote about not liking initializing validators to None - I saw a default value using the uuid function. Some minor points:
self.transformer(...)
multiple times, and while it adds an extra line I would probably do this separately immediately afterward for logical clarityLooks great to me!
Yeah good notes. I think the comment about validators might be outdated, from an earlier draft. Think I'll polish the PR a little bit and release a v3 release today or tomorrow 👍
Thanks for the really fast turnaround! I can pull directly from the branch, but before that I'll check - are you planning on releasing a version 3 anytime soon?
I released 3.0.0a1 an hour ago. You should be able to install it with pip install asgi-correlation-id==3.0.0a1
or with poetry add asgi-correlation-id==3.0.0a1 --allow-prereleases
. Was hoping to run the pre-release for a day then release v3 tomorrow morning 👍
Hi,
I would love to be able to use ULID in place of uuid4, and sadly the choice is hardcoded, not something that can easily be worked around. Either providing something like ulid as an alternative, or allowing for the provision of a generator (/validator) method that could be injected would do the job. I'm a little hard pressed to create a PR myself, but I was wondering if this could make it onto a roadmap?
Thanks and love the package!