Skip to content

Commit

Permalink
Add rack 2 backwards compat (#4)
Browse files Browse the repository at this point in the history
`rack` version 2 two requires a `rack.input`, other than that
it is 100% compatible with version 3 when it comes to the
methods that linzer uses.

Relaxing the version requirement this way allows people to
adopt linzer that are stuck on `rack` 2 for whatever reason.
  • Loading branch information
oneiros authored Dec 2, 2024
1 parent 8ee9997 commit 7481f31
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PATH
linzer (0.6.0)
ed25519 (~> 1.3, >= 1.3.0)
openssl (~> 3.0, >= 3.0.0)
rack (~> 3.0)
rack (>= 2.2, < 4.0)
starry (~> 0.2)
uri (~> 0.12, >= 0.12.0)

Expand All @@ -25,7 +25,7 @@ GEM
ast (~> 2.4.1)
racc
racc (1.7.3)
rack (3.0.11)
rack (3.1.8)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.0)
Expand Down
3 changes: 2 additions & 1 deletion lib/linzer/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def build(verb, uri = "/", params = {}, headers = {})
request_method = Rack.const_get(verb.upcase)
args = {
"REQUEST_METHOD" => request_method,
"PATH_INFO" => uri.to_str
"PATH_INFO" => uri.to_str,
"rack.input" => StringIO.new
}

Rack::Request.new(build_rack_env(headers).merge(args))
Expand Down
2 changes: 1 addition & 1 deletion linzer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "openssl", "~> 3.0", ">= 3.0.0"
spec.add_runtime_dependency "ed25519", "~> 1.3", ">= 1.3.0"
spec.add_runtime_dependency "starry", "~> 0.2"
spec.add_runtime_dependency "rack", "~> 3.0"
spec.add_runtime_dependency "rack", ">= 2.2", "< 4.0"
spec.add_runtime_dependency "uri", "~> 0.12", ">= 0.12.0"
end

0 comments on commit 7481f31

Please sign in to comment.