salestation 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/salestation/web/request_logger.rb +12 -6
- data/salestation.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd559bbf097cf1fddbed26a70e5d13030daba5fd
|
4
|
+
data.tar.gz: 6cb905bdbcefb11fc449cf0de625bbcbcf969cec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5e21a6205a7b15145b41eb6ff7724947953ac47dd3447cca406bd85f0891780cc371f8fba567bf0ea163c8dd31ae5e7193e1fb176423e4333760c32a3d363d5
|
7
|
+
data.tar.gz: 59c781a5f0c3a078699a41cf8485a174a49ae4c08abdf9c2ced6134c380ba3bb8e84d8768b9de6a86bc25ff10297042e4e737638940437b90c08b3aead604b02
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'json'
|
3
|
+
|
1
4
|
module Salestation
|
2
5
|
class Web < Module
|
3
6
|
class RequestLogger
|
@@ -12,9 +15,10 @@ module Salestation
|
|
12
15
|
SERVER_NAME = 'SERVER_NAME'.freeze
|
13
16
|
JSON_CONTENT_TYPE = 'application/json'.freeze
|
14
17
|
|
15
|
-
def initialize(app, logger)
|
18
|
+
def initialize(app, logger, log_response_body: true)
|
16
19
|
@app = app
|
17
20
|
@logger = logger
|
21
|
+
@log_response_body = log_response_body
|
18
22
|
end
|
19
23
|
|
20
24
|
def call(env)
|
@@ -49,9 +53,11 @@ module Salestation
|
|
49
53
|
def response_log(env, status, headers, body, began_at)
|
50
54
|
response_payload =
|
51
55
|
if status >= 400
|
52
|
-
{ error: parse_body(body) }
|
56
|
+
{ error: parse_body(body, env) }
|
57
|
+
elsif @log_response_body
|
58
|
+
{ body: parse_body(body, env) }
|
53
59
|
else
|
54
|
-
{
|
60
|
+
{}
|
55
61
|
end
|
56
62
|
|
57
63
|
{
|
@@ -63,12 +69,12 @@ module Salestation
|
|
63
69
|
}.merge(response_payload)
|
64
70
|
end
|
65
71
|
|
66
|
-
def parse_body(body)
|
72
|
+
def parse_body(body, env)
|
67
73
|
begin
|
68
74
|
# Rack body is an array
|
69
|
-
JSON.parse(body.join
|
75
|
+
JSON.parse(body.join)
|
70
76
|
rescue Exception
|
71
|
-
{error:
|
77
|
+
{error: 'Failed to parse response body'}
|
72
78
|
end
|
73
79
|
end
|
74
80
|
|
data/salestation.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: salestation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SaleMove TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|