lib/async/http/middleware/builder.rb in async-http-0.27.1 vs lib/async/http/middleware/builder.rb in async-http-0.27.2

- old
+ new

@@ -16,17 +16,28 @@ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. + + module Async module HTTP class Middleware + module NotFound + def self.close + end + + def self.call(request) + Response[404, {}, []] + end + end + class Builder - def initialize(default_app = nil, &block) + def initialize(default_app = NotFound, &block) @use = [] - @run = default_app + @app = default_app instance_eval(&block) if block_given? end def use(middleware, *args, &block) @@ -36,10 +47,10 @@ def run(app) @app = app end def to_app - app = @use.reverse.inject(app) {|app, use| use.call(app).freeze} + @use.reverse.inject(@app) {|app, use| use.call(app).freeze} end end def self.build(&block) Builder.new(&block).to_app