From e26a427ded04bd4da2319578c39afb51df227eb3 Mon Sep 17 00:00:00 2001 From: Ben Fritsch Date: Tue, 13 Feb 2024 10:46:19 +0100 Subject: [PATCH] add support for Sinatra 4 --- .github/workflows/ruby.yml | 2 +- lib/pliny/middleware/cors.rb | 12 ++++++------ lib/pliny/middleware/versioning.rb | 2 +- pliny.gemspec | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 613b31e9..ad619806 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -14,7 +14,7 @@ jobs: matrix: ruby-version: ['3.0', '3.1', '3.2'] activesupport-version: ['6', '7'] - sinatra-version: ['2', '3'] + sinatra-version: ['2', '3', '4'] env: ACTIVESUPPORT_MAJOR: ${{ matrix.activesupport-version }} SINATRA_MAJOR: ${{ matrix.sinatra-version }} diff --git a/lib/pliny/middleware/cors.rb b/lib/pliny/middleware/cors.rb index 813bb691..430ebd18 100644 --- a/lib/pliny/middleware/cors.rb +++ b/lib/pliny/middleware/cors.rb @@ -44,12 +44,12 @@ def allow_headers def cors_headers(env) { - 'Access-Control-Allow-Origin' => env["HTTP_ORIGIN"], - 'Access-Control-Allow-Methods' => ALLOW_METHODS.join(', '), - 'Access-Control-Allow-Headers' => allow_headers.join(', '), - 'Access-Control-Allow-Credentials' => "true", - 'Access-Control-Max-Age' => "1728000", - 'Access-Control-Expose-Headers' => EXPOSE_HEADERS.join(', ') + 'access-control-allow-origin' => env["HTTP_ORIGIN"], + 'access-control-allow-methods' => ALLOW_METHODS.join(', '), + 'access-control-allow-headers' => allow_headers.join(', '), + 'access-control-allow-credentials' => "true", + 'access-control-max-age' => "1728000", + 'access-control-expose-headers' => EXPOSE_HEADERS.join(', ') } end end diff --git a/lib/pliny/middleware/versioning.rb b/lib/pliny/middleware/versioning.rb index 900923ea..57f1fd16 100644 --- a/lib/pliny/middleware/versioning.rb +++ b/lib/pliny/middleware/versioning.rb @@ -26,7 +26,7 @@ def detect_api_version(env) error = { id: :bad_version, message: <<-eos } Please specify a version along with the MIME type. For example, `Accept: application/vnd.#{@app_name}+json; version=1`. eos - return [400, { "Content-Type" => "application/json; charset=utf-8" }, + return [400, { "content-type" => "application/json; charset=utf-8" }, [MultiJson.encode(error)]] end diff --git a/pliny.gemspec b/pliny.gemspec index e764a94f..a013c0a1 100644 --- a/pliny.gemspec +++ b/pliny.gemspec @@ -20,15 +20,15 @@ Gem::Specification.new do |gem| gem.add_dependency "prmd", "~> 0.11", ">= 0.11.4" - gem.add_dependency "sinatra", ">= 2.0", "< 4.0" + gem.add_dependency "sinatra", ">= 2.0", "< 5.0" gem.add_dependency "http_accept", "~> 0.1", ">= 0.1.5" gem.add_dependency "sinatra-router", "~> 0.2", ">= 0.2.4" gem.add_dependency "thor", ">= 0.19", "< 2.0" gem.add_development_dependency "rake", "~> 13.0" - gem.add_development_dependency "rack-test", "~> 1.1.0" + gem.add_development_dependency "rack-test", "~> 2" gem.add_development_dependency "rspec", "~> 3.1", ">= 3.1.0" - gem.add_development_dependency "sinatra-contrib", ">= 2.0", "< 4.0" + gem.add_development_dependency "sinatra-contrib", ">= 2.0", "< 5.0" gem.add_development_dependency "timecop", "~> 0.7", ">= 0.7.1" gem.add_development_dependency "pry" gem.add_development_dependency "pry-byebug"