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 +23 -11
- data/lib/rack-request-id/version.rb +1 -1
- data/lib/rack/request_id.rb +2 -2
- data/rack-request-id.gemspec +2 -2
- metadata +6 -6
data/README.md
CHANGED
@@ -1,24 +1,36 @@
|
|
1
1
|
# Rack::RequestId
|
2
2
|
|
3
|
-
|
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
|
-
##
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
6
|
+
## Usage
|
8
7
|
|
9
|
-
|
8
|
+
```ruby
|
9
|
+
gem 'rack-request-id'
|
10
|
+
```
|
10
11
|
|
11
|
-
|
12
|
+
#### Sinatra
|
12
13
|
|
13
|
-
|
14
|
+
```ruby
|
15
|
+
class MyApp < Sinatra::Base
|
16
|
+
use Rack::RequestId
|
17
|
+
end
|
18
|
+
```
|
14
19
|
|
15
|
-
|
20
|
+
#### Rails
|
16
21
|
|
17
|
-
|
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
|
-
##
|
31
|
+
## Configuration
|
20
32
|
|
21
|
-
TODO:
|
33
|
+
TODO: proc option to override id format
|
22
34
|
|
23
35
|
## Contributing
|
24
36
|
|
data/lib/rack/request_id.rb
CHANGED
@@ -7,9 +7,9 @@ module Rack
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call(env)
|
10
|
-
request_id =
|
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
|
data/rack-request-id.gemspec
CHANGED
@@ -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
|
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.
|
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-
|
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
|
53
|
+
summary: Adds a 16-digit hexidecimal X-Request-Id header if none exists.
|
54
54
|
test_files: []
|