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 +4 -4
- data/README.md +1 -1
- data/lib/marcopolo/middleware.rb +10 -8
- data/lib/marcopolo/rails.rb +1 -1
- data/lib/marcopolo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d7b9c6170d11433cef35c60dc59c7381d465796
|
4
|
+
data.tar.gz: 79e60dc711051916638470ae3605c6d0a836acf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/marcopolo/middleware.rb
CHANGED
@@ -7,22 +7,22 @@ module Marcopolo
|
|
7
7
|
def call(env)
|
8
8
|
@request = Rack::Request.new(env)
|
9
9
|
|
10
|
-
|
10
|
+
allow = Marcopolo.allow(@request)
|
11
11
|
|
12
|
-
if
|
13
|
-
|
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
|
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,
|
data/lib/marcopolo/rails.rb
CHANGED
@@ -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
|
4
|
+
app.middleware.insert_before Rack::Runtime, "Marcopolo::Middleware"
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
data/lib/marcopolo/version.rb
CHANGED