snok / asgi-correlation-id

Request ID propagation for ASGI apps
MIT License
370 stars 29 forks source link

Improve middleware configurability #15

Closed sondrelg closed 2 years ago

sondrelg commented 2 years ago

PR adds some more middleware arguments, which I think will make it a lot more flexible.

Changes

PR adds:

Adding a generator makes it possible to supply other ID-generators, like nanoid. All we expect from a correlation/request ID header is for the value to be unique.

Adding the possibility of passing custom validators moves us away from UUID-based validation, which should make the middleware more flexible.

Adding a transformer would make it possible to solve #13 by stripping dashes and lowercasing UUID-formatted request IDs, if that's something you wanted. There are multiple possible uses for this, and with it added users will have full access to handle request IDs as they need.

Thoughts

TODO:

codecov[bot] commented 2 years ago

Codecov Report

Merging #15 (e9fe16f) into main (ca9691f) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main       #15   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         7    +1     
  Lines          129       137    +8     
=========================================
+ Hits           129       137    +8     
Impacted Files Coverage Δ
asgi_correlation_id/middleware.py 100.00% <100.00%> (ø)
asgi_correlation_id/validators.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ca9691f...e9fe16f. Read the comment docs.

Goldziher commented 2 years ago

LGTM

sonarcloud[bot] commented 2 years ago

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 4 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication