foobara-http-command-connector 0.0.19 → 0.0.20
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/CHANGELOG.md +4 -0
- data/src/http/commands/describe.rb +1 -1
- data/src/http/commands/get_options.rb +38 -0
- data/src/http.rb +7 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84f98d62ccf5d4607dfa7fcec72c146783afdcaf05fea4c6a783886d51a76446
|
4
|
+
data.tar.gz: d5d43e938ff41147061148b8fdac2bc15f54dfa8303f3b3225079d49d880d200
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40d905a7991b607b9b1dae7604969cb1eb40f357c1850bc743f2200a27badce71d6fc76d13680c348216047ec3c67587e83f23730657319839301c5c536e82bc
|
7
|
+
data.tar.gz: 3a81ef2395e42ad2027b86d5e21651b3e9ba95db4be779964d0a954e025336a67bb01ac0aa91ab539d58076dcbd2663bdc5196cf10c177849f252bffed462f81
|
data/CHANGELOG.md
CHANGED
@@ -4,11 +4,49 @@ module Foobara
|
|
4
4
|
module Commands
|
5
5
|
# TODO: this is a bit of a hack, just a total no-op... shouldn't really need this command at all ideally
|
6
6
|
class GetOptions < Foobara::Command
|
7
|
+
inputs do
|
8
|
+
request :duck, :required
|
9
|
+
end
|
7
10
|
result :string
|
8
11
|
|
9
12
|
def execute
|
13
|
+
initialize_response_headers
|
14
|
+
|
15
|
+
set_allow_methods
|
16
|
+
set_allow_headers
|
17
|
+
set_access_control_max_age
|
18
|
+
|
19
|
+
# TODO: what's with this empty string?
|
10
20
|
""
|
11
21
|
end
|
22
|
+
|
23
|
+
def initialize_response_headers
|
24
|
+
request.response_headers ||= {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def set_allow_methods
|
28
|
+
allow_methods = ENV.fetch("FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS", nil)
|
29
|
+
if allow_methods
|
30
|
+
request.response_headers["access-control-allow-methods"] = allow_methods
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_allow_headers
|
35
|
+
allow_headers = ENV.fetch("FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS", nil)
|
36
|
+
if allow_headers
|
37
|
+
if allow_headers == "*"
|
38
|
+
allow_headers = request.headers["HTTP_ACCESS_CONTROL_REQUEST_HEADERS"]
|
39
|
+
end
|
40
|
+
request.response_headers["access-control-allow-headers"] = allow_headers
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def set_access_control_max_age
|
45
|
+
access_control_max_age = ENV.fetch("FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE", nil)
|
46
|
+
if access_control_max_age
|
47
|
+
request.response_headers["access-control-max-age"] = access_control_max_age
|
48
|
+
end
|
49
|
+
end
|
12
50
|
end
|
13
51
|
end
|
14
52
|
end
|
data/src/http.rb
CHANGED
@@ -60,13 +60,11 @@ module Foobara
|
|
60
60
|
|
61
61
|
def request_to_command(request)
|
62
62
|
if request.method == "OPTIONS"
|
63
|
-
|
64
|
-
return Foobara::CommandConnectors::Http::Commands::GetOptions.new
|
63
|
+
return Foobara::CommandConnectors::Http::Commands::GetOptions.new(request:)
|
65
64
|
end
|
66
65
|
|
67
66
|
command = super
|
68
67
|
|
69
|
-
# TODO: We should kill these case statements and require connecting these commands
|
70
68
|
if request.action == "help"
|
71
69
|
command.class.serializers = [Commands::Help::ResultSerializer]
|
72
70
|
end
|
@@ -136,6 +134,12 @@ module Foobara
|
|
136
134
|
|
137
135
|
def static_headers
|
138
136
|
@static_headers ||= ENV.each_with_object({}) do |(key, value), headers|
|
137
|
+
next if %w[
|
138
|
+
FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS
|
139
|
+
FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS
|
140
|
+
FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE
|
141
|
+
].include?(key)
|
142
|
+
|
139
143
|
match = key.match(/\AFOOBARA_HTTP_RESPONSE_HEADER_(.*)\z/)
|
140
144
|
|
141
145
|
if match
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-http-command-connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: foobara
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
|
-
rubygems_version: 3.6.
|
97
|
+
rubygems_version: 3.6.7
|
98
98
|
specification_version: 4
|
99
99
|
summary: No description. Add one.
|
100
100
|
test_files: []
|