Add class Diversipub::RackApp
This commit is contained in:
parent
6ba8ca10ae
commit
4a2820f081
3 changed files with 31 additions and 0 deletions
|
@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
|
|||
|
||||
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename f }
|
||||
|
||||
spec.add_runtime_dependency 'rack', '~> 2.2', '>= 2.2.7'
|
||||
spec.add_runtime_dependency 'sinatra', '~> 3.0', '>= 3.0.6'
|
||||
|
||||
spec.add_development_dependency 'pry', '~> 0.14'
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rack'
|
||||
require 'sinatra/base'
|
||||
|
||||
require_relative 'diversipub/main'
|
||||
require_relative 'diversipub/rack_app'
|
||||
require_relative 'diversipub/sinatra_app'
|
||||
require_relative 'diversipub/version'
|
||||
|
|
28
lib/diversipub/rack_app.rb
Normal file
28
lib/diversipub/rack_app.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Diversipub
|
||||
##
|
||||
# Rack web application.
|
||||
#
|
||||
class RackApp
|
||||
def initialize(sinatra_app)
|
||||
@sinatra_app = sinatra_app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
to_app.call env
|
||||
end
|
||||
|
||||
def to_app
|
||||
@to_app ||= builder.to_app
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def builder
|
||||
@builder ||= Rack::Builder.new.tap do |builder|
|
||||
builder.run @sinatra_app
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue