Sha256: eb946959b043a3572fda3329b897a2d41c8124ac11060f7899f9facec2214a87
Contents?: true
Size: 649 Bytes
Versions: 2
Compression:
Stored size: 649 Bytes
Contents
# frozen_string_literal: true require 'fileutils' require 'tipi' require_relative './resource' module Impression # The `RackApp` class represents Rack apps as resources. class RackApp < Resource def initialize(app: nil, **props, &block) raise "No Rack app given" unless app || block # We pass nil as the block, otherwise the block will pass to # Resource#initialize, which will cause #call to be overidden. super(**props, &nil) @handler = Tipi::RackAdapter.run(app || block) end def call(req) if @path != '/' req.rewrite!(@path, '/') end @handler.(req) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
impression-0.13 | lib/impression/rack_app.rb |
impression-0.12 | lib/impression/rack_app.rb |