Sha256: 4a3cd8603ffe9d1779d1d912a1ef826cc787b6f29959f76a51956cdec8631e10
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
# code: # * George Moschovitis <gm@navel.gr> # # (c) 20024 Navel, all rights reserved. # $Id: filters.rb 152 2004-11-13 20:02:35Z gmosx $ require "socket" require "thread" require "sync" module N # == Filter # # A server serves client requests by feeding the request/request pair # to a pipeline of processing filters. This is not a simple linear pipeline. # Instead it is what we call a 'folding' (hierarchical) pipeline: each # filter encapsulates the next. In effect, the pipeline is a generalized # filter! # # === Design: # # Filters are NOT singleton classes. This way we can assign one filter # class to multiple resources, and keep statistics and metrics for # each resource. # A filter may contain state (attributes) for example metrics. # class ServerFilter # the next filter in the pipeline. attr_reader :next_filter # set the filters next. # # example: # LogFilter.new(TimeFilter.new(PageFilter.new)) # def initialize(next_filter = nil) @next_filter = next_filter end # set the filters next (next_filter). # # example: # LogFilter.new << TimeFilter.new << PageFilter.new # def << (next_filter = nil) @next_filter = next_filter end # Override this method to implement your filter. # def process(request) # preprocessing comes here... # walk the pipeline return process_next(request) # postprocessing comes here... # return the result... end # Process the next filter in the pipeline # def process_next(request) if @next_filter return @next_filter.process(request) else return nil end end end end # module
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.4.1 | lib/nitro/server/filters.rb |
nitro-0.5.0 | lib/nitro/server/filters.rb |
nitro-0.6.0 | lib/nitro/server/filters.rb |