foobara-http-command-connector 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/src/http/request.rb +18 -3
- data/src/http.rb +27 -0
- 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: f5ccda00e728fcacf8da3a8aa2c457f47b1f4b3eea9c93c2ce5446bc8114be4c
|
4
|
+
data.tar.gz: fcd50e3249e2b0c66fa7ae2a778e5553dd21ad376277122a0593ddd3c16e1d43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54391b8b5be54090a5441753902b9a692ad1f02fbc4cd38d0aad272da57367830e20b02745e2b7682fcd3477588ddd6cef1cff3ed67e1be32c5494adfcda9b7e
|
7
|
+
data.tar.gz: 7d6f18ee723458727316adfbadd2ca1f8b2a08b3d671db99a1f522d527f5b500373ca3cb624015be2c80677710bb1f3fa95ef3def09ef3cdc4a16a24f5fa9798
|
data/CHANGELOG.md
CHANGED
data/src/http/request.rb
CHANGED
@@ -13,6 +13,7 @@ module Foobara
|
|
13
13
|
:host,
|
14
14
|
:port,
|
15
15
|
:cookies,
|
16
|
+
:prefix,
|
16
17
|
:remote_ip,
|
17
18
|
:response_headers
|
18
19
|
|
@@ -26,7 +27,8 @@ module Foobara
|
|
26
27
|
host: nil,
|
27
28
|
port: nil,
|
28
29
|
cookies: nil,
|
29
|
-
remote_ip: nil
|
30
|
+
remote_ip: nil,
|
31
|
+
prefix: nil
|
30
32
|
)
|
31
33
|
self.path = path
|
32
34
|
self.method = method
|
@@ -38,6 +40,7 @@ module Foobara
|
|
38
40
|
self.port = port
|
39
41
|
self.cookies = cookies
|
40
42
|
self.remote_ip = remote_ip
|
43
|
+
self.prefix = prefix
|
41
44
|
|
42
45
|
super()
|
43
46
|
end
|
@@ -86,11 +89,23 @@ module Foobara
|
|
86
89
|
end
|
87
90
|
|
88
91
|
def argument
|
89
|
-
|
92
|
+
prefixless_path.split("/")[2]
|
90
93
|
end
|
91
94
|
|
92
95
|
def set_action_and_command_name
|
93
|
-
@action, @full_command_name =
|
96
|
+
@action, @full_command_name = prefixless_path[1..].split("/")
|
97
|
+
end
|
98
|
+
|
99
|
+
def prefixless_path
|
100
|
+
return @prefixless_path if defined?(@prefixless_path)
|
101
|
+
|
102
|
+
prefix = self.prefix
|
103
|
+
|
104
|
+
@prefixless_path = if prefix
|
105
|
+
path.gsub(/^#{prefix}\//, "/")
|
106
|
+
else
|
107
|
+
path
|
108
|
+
end
|
94
109
|
end
|
95
110
|
end
|
96
111
|
end
|
data/src/http.rb
CHANGED
@@ -3,6 +3,33 @@ module Foobara
|
|
3
3
|
class Http < CommandConnector
|
4
4
|
include TruncatedInspect
|
5
5
|
|
6
|
+
attr_accessor :prefix
|
7
|
+
|
8
|
+
def initialize(prefix: nil, **)
|
9
|
+
if prefix
|
10
|
+
if prefix.is_a?(::Array)
|
11
|
+
prefix = prefix.join("/")
|
12
|
+
end
|
13
|
+
|
14
|
+
if prefix.end_with?("/")
|
15
|
+
prefix = prefix[0..-2]
|
16
|
+
end
|
17
|
+
|
18
|
+
unless prefix.start_with?("/")
|
19
|
+
prefix = "/#{prefix}"
|
20
|
+
end
|
21
|
+
|
22
|
+
self.prefix = prefix
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
super(**)
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(*, **)
|
30
|
+
super(*, prefix:, **)
|
31
|
+
end
|
32
|
+
|
6
33
|
def request_to_command(context)
|
7
34
|
if context.method == "OPTIONS"
|
8
35
|
# TODO: this feels a bit hacky and like overkill...
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: foobara
|