foobara-http-command-connector 0.0.19 → 0.0.21
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 +8 -0
- data/src/http/commands/describe.rb +1 -1
- data/src/http/commands/get_options.rb +38 -0
- data/src/http/request.rb +8 -0
- data/src/http.rb +8 -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: 5eb43075a767f1e385f262e2d15e1fa497a6835239fcd31ddeb684557f46d7cf
|
4
|
+
data.tar.gz: 13368b595132e123cfa2cb96510713e6ac282ca8fa55fbb052e529b98a58aee4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22be5baa2d2174b415a37db548f53af808b2f6d84b43692636a380e5d508f9b10ff1853b62ddea0734e336a2d84302043599baa5c785646efc92b65fe9c76c25
|
7
|
+
data.tar.gz: 07a3d553c35bef5eea9e929f3d91ac0b68785648af4169666c1debc159da2257d2dbe17511ecfec73c827435b9d20fd576454e62a6c8374927dd0e48513e81c7
|
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["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/request.rb
CHANGED
@@ -109,6 +109,14 @@ module Foobara
|
|
109
109
|
path
|
110
110
|
end
|
111
111
|
end
|
112
|
+
|
113
|
+
def set_response_header(name, value)
|
114
|
+
name = name.to_s
|
115
|
+
name = name.downcase
|
116
|
+
|
117
|
+
self.response_headers ||= {}
|
118
|
+
self.response_headers = response_headers.merge(name => value)
|
119
|
+
end
|
112
120
|
end
|
113
121
|
end
|
114
122
|
end
|
data/src/http.rb
CHANGED
@@ -60,14 +60,13 @@ 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"
|
69
|
+
request.set_response_header("content-type", "text/html")
|
71
70
|
command.class.serializers = [Commands::Help::ResultSerializer]
|
72
71
|
end
|
73
72
|
|
@@ -136,6 +135,12 @@ module Foobara
|
|
136
135
|
|
137
136
|
def static_headers
|
138
137
|
@static_headers ||= ENV.each_with_object({}) do |(key, value), headers|
|
138
|
+
next if %w[
|
139
|
+
FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_HEADERS
|
140
|
+
FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS
|
141
|
+
FOOBARA_HTTP_RESPONSE_HEADER_ACCESS_CONTROL_MAX_AGE
|
142
|
+
].include?(key)
|
143
|
+
|
139
144
|
match = key.match(/\AFOOBARA_HTTP_RESPONSE_HEADER_(.*)\z/)
|
140
145
|
|
141
146
|
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.21
|
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: []
|