marcopolo 0.0.2 → 0.0.3

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: afc67f4a1453ec6bb4f6eee5c4416c72f8b9b9e1
4
- data.tar.gz: f1f2349517951a120298d76dcf9e40b0db217161
3
+ metadata.gz: 3d7b9c6170d11433cef35c60dc59c7381d465796
4
+ data.tar.gz: 79e60dc711051916638470ae3605c6d0a836acf5
5
5
  SHA512:
6
- metadata.gz: bee378b9d266328c4be7a3a196e0b44b3d3b31c5795caf1674bc1d2862188badfd90267954cf624ee8921a5f04447e71781d5847449c575960edbcfc231eef4c
7
- data.tar.gz: 61b0b157dafd8cca699c0f49ded943f9087f464e53a9d1764201c793804ad9442062f3d4dddf3c2465f04758d2db0d3fa37be07d87f1b6663e10d32d0ae4db5f
6
+ metadata.gz: 5181e779ffab1fd41bc20f93e3815351c05c79b97a8024a6f661b7aada28ee832a9732382a50ec12e42246ab9283641a0a6503ce29264ec2e1ab410cb3e9cc69
7
+ data.tar.gz: 3dd424e72bfae1f83c6e6fa6746407becc7a56cba6d2cd57fa68847a3886a3720b2cfe02f2245d561c05a70897b074db3b0869112ad8536c782dae4ba3925923
data/README.md CHANGED
@@ -31,7 +31,7 @@ You may want to filter out noisy requests, such as health checks. Create a proc
31
31
 
32
32
  Marcopolo.options[:filter] = Proc.new do |request|
33
33
  # exclude all options requests
34
- request.request_method != 'OPTIONS']
34
+ request.request_method != 'OPTIONS'
35
35
  end
36
36
 
37
37
  ## TODO
@@ -7,22 +7,22 @@ module Marcopolo
7
7
  def call(env)
8
8
  @request = Rack::Request.new(env)
9
9
 
10
- @status, @headers, @response = @app.call(env)
10
+ allow = Marcopolo.allow(@request)
11
11
 
12
- if Marcopolo.allow(@request)
13
- begin
14
- rawlog(env)
15
- rescue => e
16
- Marcopolo.log "Failed to log request: #{e.message}"
17
- end
12
+ if allow
13
+ rawlog_request(env)
18
14
  else
19
15
  Marcopolo.log "Filtering request: #{@request.request_method} #{@request.url}"
20
16
  end
21
17
 
18
+ @status, @headers, @response = @app.call(env)
19
+
20
+ rawlog_response(env) if allow
21
+
22
22
  return [@status, @headers, @response]
23
23
  end
24
24
 
25
- def rawlog(env)
25
+ def rawlog_request(env)
26
26
  req_headers = env.select {|k,v| k.start_with? 'HTTP_'}
27
27
  .collect {|pair| [pair[0].sub(/^HTTP_/, '').split('_').map(&:titleize).join('-'), pair[1]]}
28
28
  .sort
@@ -42,7 +42,9 @@ module Marcopolo
42
42
  })
43
43
 
44
44
  Marcopolo.log req_hash.to_a.map {|o| o.join(': ') }.join("\n") + "\n"
45
+ end
45
46
 
47
+ def rawlog_response(env)
46
48
  resp_hash = {
47
49
  "RESPONSE" => "",
48
50
  "Response Status" => @status,
@@ -1,7 +1,7 @@
1
1
  module Marcopolo
2
2
  class Marco < Rails::Railtie
3
3
  initializer "marcopolo.configure_rails_initialization" do |app|
4
- app.middleware.insert_before ActionDispatch::ParamsParser, "Marcopolo::Middleware"
4
+ app.middleware.insert_before Rack::Runtime, "Marcopolo::Middleware"
5
5
  end
6
6
  end
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module Marcopolo
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marcopolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Hammond