file_sv 0.1.13 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/file_sv/planned_endpoint.rb +13 -0
- data/lib/file_sv/version.rb +1 -1
- data/lib/file_sv/virtual_server.rb +13 -3
- 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: 7177e3a064f21ddcd10c0e939d9557460e23a260d247cfbed515a94a5b9265a3
|
4
|
+
data.tar.gz: e5cc7b549e0d6264a2a357a00de1d85ef18b7aafa757c621c0eeb647bc6db332
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61d515119cc7b4d3cefca1f8231c2d85f51394518e448013b4457271f01dddffd370426a5f4077bd5c05f7a446085643524c2968a443b0a1fd8fd86a5b3a6276
|
7
|
+
data.tar.gz: 96c064f198dbea63b6c5f251f4b2758856759f604cf8b3f3e31ccbb80fc895ee9d8861fe486e605d6a01feaab5f848a46d81501beadd1f1fee975d7bec9de146
|
@@ -130,6 +130,19 @@ class PlannedEndpoint
|
|
130
130
|
ERB.new(File.read(serving_file_name)).result(binding)
|
131
131
|
end
|
132
132
|
|
133
|
+
# Log when API is called
|
134
|
+
def log_call(params)
|
135
|
+
if params.keys.count > 0
|
136
|
+
show_params = []
|
137
|
+
params.each do |key, value|
|
138
|
+
show_params << "#{key}=#{value}"
|
139
|
+
end
|
140
|
+
"#{self.method} #{self.path}?#{show_params.join('&')}"
|
141
|
+
else
|
142
|
+
"#{self.method} #{self.path}"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
133
146
|
def short_description
|
134
147
|
desc = self.status_code.to_s
|
135
148
|
desc += " (delay #{self.delay} sec)" if self.delay > 0
|
data/lib/file_sv/version.rb
CHANGED
@@ -58,7 +58,7 @@ for more details'
|
|
58
58
|
[endpoint.status_code, output_for(endpoint, binding)]
|
59
59
|
end
|
60
60
|
|
61
|
-
SvPlan.endpoints.each do |
|
61
|
+
SvPlan.endpoints.each do |endpoint_path, endpoint_value|
|
62
62
|
endpoint_value.each do |_method_name, endpoints|
|
63
63
|
endpoint_base = endpoints[0]
|
64
64
|
documentation "Endpoint #{endpoint_base.path}" do
|
@@ -66,19 +66,29 @@ for more details'
|
|
66
66
|
end
|
67
67
|
if endpoint_base.path.include? "#{File::Separator}:"
|
68
68
|
send(endpoint_base.method, endpoint_base.path) do |id|
|
69
|
+
response["Access-Control-Allow-Origin"] = "*"
|
69
70
|
endpoint = endpoints.sample
|
70
71
|
@params = params
|
71
|
-
puts
|
72
|
+
puts endpoint.log_call(@params)
|
72
73
|
serve endpoint, id
|
73
74
|
end
|
74
75
|
else
|
75
76
|
send(endpoint_base.method, endpoint_base.path) do
|
77
|
+
response["Access-Control-Allow-Origin"] = "*"
|
76
78
|
endpoint = endpoints.sample
|
77
79
|
@params = params
|
78
|
-
puts
|
80
|
+
puts endpoint.log_call(@params) unless ENV['ignore_path'] && ("/#{ENV['ignore_path']}" == endpoint_base.path)
|
79
81
|
serve endpoint
|
80
82
|
end
|
81
83
|
end
|
82
84
|
end
|
85
|
+
# options endpoint for CORS
|
86
|
+
options endpoint_path do
|
87
|
+
puts "options: #{endpoint_path}"
|
88
|
+
response["Allow"] = "*"
|
89
|
+
response["Access-Control-Allow-Origin"] = "*"
|
90
|
+
response["Access-Control-Allow-Methods"] = "*"
|
91
|
+
response["Access-Control-Allow-Headers"] = "*"
|
92
|
+
end
|
83
93
|
end
|
84
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_sv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Garratt
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faker
|