Sha256: 6bbd86780bd373a108334a1b3a27bf724d0632ce388f0ee050c2fade9b4edd6c
Contents?: true
Size: 879 Bytes
Versions: 1
Compression:
Stored size: 879 Bytes
Contents
# This file is part of the "Utopia Framework" project, and is licensed under the GNU AGPLv3. # Copyright 2010 Samuel Williams. All rights reserved. # See <utopia.rb> for licensing details. require 'utopia/middleware' require 'utopia/path' require 'time' require 'digest/sha1' require 'mime/types' module Utopia module Middleware # This class filters a incoming request and only executes a given block if it matches the given filter path. class Filter def initialize(app, filter, &block) @app = app @filter = filter branch = Rack::Builder.new(&block) branch.run(@app) @process = branch.to_app end def applicable(request) return request.path.index(@filter) != nil end def call(env) request = Rack::Request.new(env) if applicable(request) @process.call(env) else @app.call(env) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
utopia-0.9.39 | lib/utopia/middleware/filter.rb |