Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[middleware] Rack::BlastWave::RequestId middleware #1

Merged
merged 11 commits into from
Aug 12, 2018
Merged

Conversation

0exp
Copy link
Owner

@0exp 0exp commented Aug 12, 2018

  • gives an unique request identificator to the each request
use Rack::BlastWave::RequestId

request.env['rack.blastwave.request_id'] # => "80f31ba599bd9b9449ea6f2061f40666"
request.request_id # => "80f31ba599bd9b9449ea6f2061f40666"
  • you can setup a custom id randomizer (by providing a #call-able object):
Rack::BlastWave::RequestId.configure do |conf|
  random_values = %w[hello world].cycle
  conf.id_randomizer = -> { random_values.next }
end

# first request...
request.request_id # => "hello"
# second request...
request.request_id # => "world"
# third request...
request.request_id # => "hello"
# and etc...

@0exp 0exp self-assigned this Aug 12, 2018
@0exp 0exp added the feature label Aug 12, 2018
@0exp 0exp added this to the 0.1.0 milestone Aug 12, 2018
@0exp 0exp merged commit c963039 into master Aug 12, 2018
@0exp 0exp deleted the feature/request-id branch August 12, 2018 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant