vigiles 0.1.0.pre.beta8 → 0.1.0.pre.beta9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vigiles/archive/request.rb +10 -1
- data/lib/vigiles/archive.rb +0 -43
- data/lib/vigiles/spec.rb +3 -3
- data/lib/vigiles/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c95b320d216c89bd72c728b2b0402cae897d984554fd6c41e66739eac544e9b
|
4
|
+
data.tar.gz: 55bd64c8191703e6d5b6aac98945c54fd9d06a65b5b094e2c338ad64c9641fb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e98f9cf83934a297eed7ac621f0200b118610690ccd1c9f51279759edce9bfa0db23bd4161adcd762a891b7a3aad6c3606d3e2d66b5ae566615c971ee3bd6460
|
7
|
+
data.tar.gz: 8b90d7d720d5104d3280aefbf6065892f24d677489ae6c096bab31a887fbc4237ac76765f0425a16ed011aaee2dba4c2828f90a6411d6cc6dff95e761eddf943
|
@@ -35,12 +35,21 @@ module Vigiles
|
|
35
35
|
const :url, T.any(URI::HTTPS, URI::HTTP)
|
36
36
|
const :id, String
|
37
37
|
|
38
|
+
sig { params(header_key: String).returns(String) }
|
39
|
+
private_class_method def self.best_effort_unfuck_http_header(header_key)
|
40
|
+
(header_key.starts_with?("HTTP_") ? T.must(header_key[5..]) : header_key)
|
41
|
+
.split(/_/)
|
42
|
+
.map(&:titlecase)
|
43
|
+
.join("-")
|
44
|
+
end
|
45
|
+
|
38
46
|
sig { params(request: ActionDispatch::Request).returns(Request) }
|
39
47
|
def self.from(request)
|
40
48
|
preferred_headers = Vigiles.spec.request_headers
|
41
49
|
available_headers = request.original_headers
|
42
50
|
recorded_headers = (available_headers if preferred_headers.empty?)
|
43
51
|
recorded_headers ||= preferred_headers.to_h { |h| [h, available_headers[h]] }
|
52
|
+
unfucked_headers = recorded_headers.transform_keys { best_effort_unfuck_http_header _1 }
|
44
53
|
|
45
54
|
Request.new(
|
46
55
|
content_type: request.content_type || (raise InvalidParameterError, "content_type"),
|
@@ -48,7 +57,7 @@ module Vigiles
|
|
48
57
|
timestamp: DateTime.now,
|
49
58
|
remote_ip: IPAddr.new(request.remote_ip),
|
50
59
|
protocol: request.protocol,
|
51
|
-
headers:
|
60
|
+
headers: unfucked_headers,
|
52
61
|
origin: request.origin || "unknown_origin_url",
|
53
62
|
payload: request.body.read,
|
54
63
|
http_method: Types::HttpMethod.deserialize(request.method),
|
data/lib/vigiles/archive.rb
CHANGED
@@ -27,48 +27,5 @@ module Vigiles
|
|
27
27
|
|
28
28
|
recorder.record(req:, res:)
|
29
29
|
end
|
30
|
-
|
31
|
-
sig do
|
32
|
-
params(
|
33
|
-
request: Request,
|
34
|
-
response: Response,
|
35
|
-
metadata: Metadata,
|
36
|
-
extras: Extras
|
37
|
-
)
|
38
|
-
.returns(T.nilable(Conversation))
|
39
|
-
end
|
40
|
-
private_class_method def self.record_json_conversation(request:, response:, metadata:, extras:)
|
41
|
-
Conversation.create!(
|
42
|
-
request_content_type: request.content_type,
|
43
|
-
request_user_agent: request.user_agent,
|
44
|
-
request_timestamp: request.timestamp,
|
45
|
-
request_remote_ip: request.remote_ip,
|
46
|
-
request_protocol: request.protocol,
|
47
|
-
request_headers: request.headers,
|
48
|
-
request_origin: request.origin,
|
49
|
-
request_payload: request.payload,
|
50
|
-
request_method: request.http_method.serialize,
|
51
|
-
request_path: request.path,
|
52
|
-
request_url: request.url,
|
53
|
-
request_id: request.id,
|
54
|
-
response_content_type: response.content_type,
|
55
|
-
response_headers: response.headers,
|
56
|
-
response_payload: response.payload,
|
57
|
-
response_status: response.status
|
58
|
-
)
|
59
|
-
rescue => e
|
60
|
-
end
|
61
|
-
|
62
|
-
sig { params(request: Request, response: Response, metadata: Metadata, extras: Extras).returns(T.nilable(Conversation)) }
|
63
|
-
private_class_method def self.record_html_conversation(request:, response:, metadata:, extras:); end
|
64
|
-
|
65
|
-
sig { params(request: Request, response: Response, metadata: Metadata, extras: Extras).returns(T.nilable(Conversation)) }
|
66
|
-
private_class_method def self.record_conversation_with_unknown_content_type(
|
67
|
-
request:,
|
68
|
-
response:,
|
69
|
-
metadata:,
|
70
|
-
extras:
|
71
|
-
)
|
72
|
-
end
|
73
30
|
end
|
74
31
|
end
|
data/lib/vigiles/spec.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
|
4
4
|
module Vigiles
|
5
5
|
class Spec < T::Struct
|
6
|
-
const :request_content_types,
|
7
|
-
const :request_headers,
|
8
|
-
const :recorders,
|
6
|
+
const :request_content_types, T::Set[String]
|
7
|
+
const :request_headers, T::Set[String]
|
8
|
+
const :recorders, T::Hash[String, ConversationRecorder]
|
9
9
|
|
10
10
|
sig { returns(Spec) }
|
11
11
|
def self.make_default_spec
|
data/lib/vigiles/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vigiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.beta9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaw Boakye
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|