rack-request-id 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,24 +1,36 @@
1
1
  # Rack::RequestId
2
2
 
3
- TODO: Write a gem description
3
+ Rack middleware which adds a 16-digit hexidecimal `X-Request-Id` header
4
+ to the response and into `Thread.current[:request_id]`
4
5
 
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
6
+ ## Usage
8
7
 
9
- gem 'rack-request-id'
8
+ ```ruby
9
+ gem 'rack-request-id'
10
+ ```
10
11
 
11
- And then execute:
12
+ #### Sinatra
12
13
 
13
- $ bundle
14
+ ```ruby
15
+ class MyApp < Sinatra::Base
16
+ use Rack::RequestId
17
+ end
18
+ ```
14
19
 
15
- Or install it yourself as:
20
+ #### Rails
16
21
 
17
- $ gem install rack-request-id
22
+ ```ruby
23
+ module MyApp
24
+ class Application < Rails::Application
25
+ # ...
26
+ config.middleware.use "Rack::RequestId"
27
+ end
28
+ end
29
+ ```
18
30
 
19
- ## Usage
31
+ ## Configuration
20
32
 
21
- TODO: Write usage instructions here
33
+ TODO: proc option to override id format
22
34
 
23
35
  ## Contributing
24
36
 
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class RequestId
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -7,9 +7,9 @@ module Rack
7
7
  end
8
8
 
9
9
  def call(env)
10
- request_id = (env['HTTP_X_REQUEST_ID'] ||= SecureRandom.hex(16))
10
+ Thread.current[:request_id] = request.env['HTTP_X_REQUEST_ID'] || SecureRandom.hex(16)
11
11
  status, headers, body = @app.call(env)
12
- headers['X-Request-Id'] ||= request_id
12
+ headers['X-Request-Id'] ||= Thread.current[:request_id]
13
13
  [status, headers, body]
14
14
  end
15
15
  end
@@ -9,8 +9,8 @@ Gem::Specification.new do |gem|
9
9
  gem.authors = ["Brian Racer"]
10
10
  gem.email = ["bracer@gmail.com"]
11
11
  gem.description = %q{Request ID Header}
12
- gem.summary = %q{Adds a request id header if none exists.}
13
- gem.homepage = ""
12
+ gem.summary = %q{Adds a 16-digit hexidecimal X-Request-Id header if none exists.}
13
+ gem.homepage = "https://github.com/anveo/rack-request-id"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
metadata CHANGED
@@ -2,14 +2,14 @@
2
2
  name: rack-request-id
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brian Racer
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-28 00:00:00.000000000 Z
12
+ date: 2013-07-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Request ID Header
15
15
  email:
@@ -27,28 +27,28 @@ files:
27
27
  - lib/rack-request-id/version.rb
28
28
  - lib/rack/request_id.rb
29
29
  - rack-request-id.gemspec
30
- homepage: ''
30
+ homepage: https://github.com/anveo/rack-request-id
31
31
  licenses: []
32
32
  post_install_message:
33
33
  rdoc_options: []
34
34
  require_paths:
35
35
  - lib
36
36
  required_ruby_version: !ruby/object:Gem::Requirement
37
+ none: false
37
38
  requirements:
38
39
  - - ! '>='
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
41
- none: false
42
42
  required_rubygems_version: !ruby/object:Gem::Requirement
43
+ none: false
43
44
  requirements:
44
45
  - - ! '>='
45
46
  - !ruby/object:Gem::Version
46
47
  version: '0'
47
- none: false
48
48
  requirements: []
49
49
  rubyforge_project:
50
50
  rubygems_version: 1.8.23
51
51
  signing_key:
52
52
  specification_version: 3
53
- summary: Adds a request id header if none exists.
53
+ summary: Adds a 16-digit hexidecimal X-Request-Id header if none exists.
54
54
  test_files: []