Sha256: 9c29d1607566ef850bf2944c449c4b5cee368807e2095ce2bad33c9d129030f8
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
# code: # * George Moschovitis <gm@navel.gr> # # (c) 20024 Navel, all rights reserved. # $Id: filters.rb 111 2004-10-27 09:30:19Z 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.3.0 | lib/n/server/filters.rb |