foobara-rack-connector 0.0.5 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fd6a9e20c23cecdf4730163edcaf946c2c1368895f9307fce0613429ec0edac
4
- data.tar.gz: 403dc1af184f985476c79f44b0d3b8830fcc72ab1fa4f80621618b619ce3ebf3
3
+ metadata.gz: 2e3ec9775e567b45fda6c338d886e57ef6e08d36c6090cd86cef5bf3f209eef4
4
+ data.tar.gz: fbc026014a46f81c15349b1b317378e15ca0ed4260261c9fc89bd0c3750924b6
5
5
  SHA512:
6
- metadata.gz: 9fa3f9b72a9262742c9009bb39280594d01c8bda3ea9216a746b3c56f47000656ba2970a4c9ef959f635d86119455ee65a494a1f2e5abcc0c439bde93f8aa11d
7
- data.tar.gz: acf9ab31874ac4bc67f698a8bb5b5563aca1c9118f3983448f17f57e0e6a76299aff9e7d821889d71b1c27661abd9830f425c908e32539ba75828ccce9017192
6
+ metadata.gz: c6dd8cb9ab3474ec36cedb89922f962353b2df83d4cbbf3c5801b6a167177302d9f79b708c50c30485710531db5f95fd9c7e5268b7e4362ffddc1de36ab004a6
7
+ data.tar.gz: c303aa82595c1a1b4e204a5c0b1f7c0643ef804e2b02853c5d3528f3e1fd63562c7373d3db1e12fd31be21308b9612d92e7a17fb8b618f52c3a6ed42b30dfcf6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.0.6] - 2025-04-17
2
+
3
+ - Add a #run_puma convenience method for demos
4
+
1
5
  ## [0.0.5] - 2025-03-29
2
6
 
3
7
  - Store cookies on request as a hash
@@ -0,0 +1,18 @@
1
+ module Foobara
2
+ module CommandConnectors
3
+ class Http < Foobara::CommandConnector
4
+ class Rack < Http
5
+ # Just a convenience method for demos. In real projects use rackup/config.ru
6
+ # or set it all up with `foob g rack-connector`
7
+ def run_puma
8
+ # :nocov:
9
+ require "puma"
10
+ require "rack/handler/puma"
11
+
12
+ Rack::Handler::Puma.run(self)
13
+ # :nocov:
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -23,12 +23,28 @@ module Foobara
23
23
  method: env["REQUEST_METHOD"],
24
24
  # TODO: should we delay this read instead of eager-loading this?
25
25
  body: env["rack.input"]&.read || "",
26
- headers: env.select { |s| s.start_with?("HTTP_") },
26
+ headers: extract_headers,
27
27
  cookies: ::Rack::Utils.parse_cookies(env),
28
28
  remote_ip: env["REMOTE_ADDR"],
29
29
  prefix:
30
30
  )
31
31
  end
32
+
33
+ private
34
+
35
+ def extract_headers
36
+ headers = {}
37
+
38
+ env.each_pair do |key, value|
39
+ next unless key.start_with?("HTTP_")
40
+
41
+ header_name = key[5..].downcase.gsub("_", "-")
42
+
43
+ headers[header_name] = value
44
+ end
45
+
46
+ headers
47
+ end
32
48
  end
33
49
  end
34
50
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-rack-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: foobara
@@ -63,6 +63,7 @@ files:
63
63
  - LICENSE-MIT.txt
64
64
  - LICENSE.txt
65
65
  - README.md
66
+ - lib/foobara/command_connectors/http/puma_runner.rb
66
67
  - lib/foobara/command_connectors/http/rack.rb
67
68
  - lib/foobara/command_connectors/http/rack/request.rb
68
69
  - lib/foobara/rack_connector.rb
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  - !ruby/object:Gem::Version
89
90
  version: '0'
90
91
  requirements: []
91
- rubygems_version: 3.6.6
92
+ rubygems_version: 3.6.7
92
93
  specification_version: 4
93
94
  summary: Exposes foobara commands and entities via rack interface.
94
95
  test_files: []