meta_request 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da748cd9fc506e4b7cc1e68f30865deae9336a86
4
- data.tar.gz: 470db6a2e4d06255893feb7a4f56966788d3f6e8
3
+ metadata.gz: aa726d98ee329e0d8f5c191fb58015b1869f407a
4
+ data.tar.gz: 6683df50b00f40428ea3161420f1874ab610ffca
5
5
  SHA512:
6
- metadata.gz: 05ce90206c87350bb4df4ff803eac40d5a99f5c7d4b62931482989a61f826645d0c88f6eb8491405cb6ff32c2c76a4e860a9cf551bb86be9d69049908b85eddc
7
- data.tar.gz: f8fd03350144072577690fa5808791aad5da180d4ed3d7d6eddd058c7af25c82d6939b405084414daad22b49675e19eb7b7d5cf6de69d9372e842e955d611544
6
+ metadata.gz: 3c17a83779def3d7466d57b2076faa5f88ece7493998c7a2f7b7e3602634f6c238c2ddef5abb97424ef23f6e19e57de65496a689dd81463d1d369dcf8793c58c
7
+ data.tar.gz: 0fbf94aa9cb729400ee9900d01913a45a76373c5c8fb2fb7853c50309703a8cbd82f0e323b0c4da0b4685dc1eadab0f358046b16577df71d0d2afbae1b63c9d2
data/README.md CHANGED
@@ -23,6 +23,12 @@ If you're using [LiveReload](http://livereload.com/) or
23
23
  exclude watching your tmp/ folder because meta_request writes a lot of data there
24
24
  and your browser will refresh like a madman.
25
25
 
26
+ ## Development
27
+
28
+ Run tests:
29
+
30
+ make
31
+
26
32
  ## Licence
27
33
 
28
34
  Copyright (c) 2012 Dejan Simic
@@ -51,7 +51,6 @@ module MetaRequest
51
51
  subscribe("process_action.action_controller.exception").
52
52
  subscribe("process_action.action_controller") do |*args|
53
53
  name, start, ending, transaction_id, payload = args
54
- payload[:format] ||= (payload[:formats]||[]).first # Rails 3.0.x Support
55
54
  payload[:status] = '500' if payload[:exception]
56
55
  Event.new(name, start, ending, transaction_id, payload)
57
56
  end.
@@ -34,6 +34,10 @@ module MetaRequest
34
34
  def json_encodable(payload)
35
35
  return {} unless payload.is_a?(Hash)
36
36
  transform_hash(payload, :deep => true) { |hash, key, value|
37
+ if value.class.to_s == 'ActionDispatch::Http::Headers'
38
+ value = value.to_h.select { |k, _| k.upcase == k }
39
+ end
40
+
37
41
  begin
38
42
  value.to_json(:methods => [:duration])
39
43
  new_value = value
@@ -3,6 +3,5 @@ module MetaRequest
3
3
  autoload :Headers, "meta_request/middlewares/headers"
4
4
  autoload :AppRequestHandler, "meta_request/middlewares/app_request_handler"
5
5
  autoload :MetaRequestHandler, "meta_request/middlewares/meta_request_handler"
6
- autoload :RequestId, "meta_request/middlewares/request_id"
7
6
  end
8
7
  end
@@ -4,7 +4,6 @@ module MetaRequest
4
4
  class Railtie < ::Rails::Railtie
5
5
 
6
6
  initializer 'meta_request.inject_middlewares' do |app|
7
- app.middleware.use Middlewares::RequestId unless defined?(ActionDispatch::RequestId)
8
7
  app.middleware.use Middlewares::MetaRequestHandler
9
8
 
10
9
  if defined? ActionDispatch::DebugExceptions
@@ -1,3 +1,3 @@
1
1
  module MetaRequest
2
- VERSION = '0.4.3'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_request
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dejan Simic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-25 00:00:00.000000000 Z
11
+ date: 2017-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 3.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 5.2.0
22
+ version: '6'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 3.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 5.2.0
32
+ version: '6'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rack-contrib
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -86,7 +86,6 @@ files:
86
86
  - lib/meta_request/middlewares/app_request_handler.rb
87
87
  - lib/meta_request/middlewares/headers.rb
88
88
  - lib/meta_request/middlewares/meta_request_handler.rb
89
- - lib/meta_request/middlewares/request_id.rb
90
89
  - lib/meta_request/railtie.rb
91
90
  - lib/meta_request/storage.rb
92
91
  - lib/meta_request/version.rb
@@ -110,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
109
  version: '0'
111
110
  requirements: []
112
111
  rubyforge_project:
113
- rubygems_version: 2.5.1
112
+ rubygems_version: 2.6.11
114
113
  signing_key:
115
114
  specification_version: 4
116
115
  summary: Request your Rails request
@@ -1,42 +0,0 @@
1
- require 'securerandom'
2
- require 'active_support/core_ext/string/access'
3
- require 'active_support/core_ext/object/blank'
4
-
5
- # Backported from Rails 3.2 (ActionDispatch::RequestId)
6
- module MetaRequest
7
- module Middlewares
8
- # Makes a unique request id available to the action_dispatch.request_id env variable (which is then accessible through
9
- # ActionDispatch::Request#uuid) and sends the same id to the client via the X-Request-Id header.
10
- #
11
- # The unique request id is either based off the X-Request-Id header in the request, which would typically be generated
12
- # by a firewall, load balancer, or the web server, or, if this header is not available, a random uuid. If the
13
- # header is accepted from the outside world, we sanitize it to a max of 255 chars and alphanumeric and dashes only.
14
- #
15
- # The unique request id can be used to trace a request end-to-end and would typically end up being part of log files
16
- # from multiple pieces of the stack.
17
- class RequestId
18
- def initialize(app)
19
- @app = app
20
- end
21
-
22
- def call(env)
23
- env["action_dispatch.request_id"] = external_request_id(env) || internal_request_id
24
- status, headers, body = @app.call(env)
25
-
26
- headers["X-Request-Id"] = env["action_dispatch.request_id"]
27
- [ status, headers, body ]
28
- end
29
-
30
- private
31
- def external_request_id(env)
32
- if request_id = env["HTTP_X_REQUEST_ID"].presence
33
- request_id.gsub(/[^\w\-]/, "").first(255)
34
- end
35
- end
36
-
37
- def internal_request_id
38
- SecureRandom.hex(16)
39
- end
40
- end
41
- end
42
- end