Sha256: 00511cf9239bd31c55f4cc76b882ba7271f3735cd3c1bde5c14074d74da3c4d8
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
# code: # * George Moschovitis <gm@navel.gr> # # (c) 20024 Navel, all rights reserved. # $Id: filters.rb 133 2004-11-10 19:08:29Z 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.7.0 | lib/nitro/server/filters.rb |
nitro-0.8.0 | lib/nitro/server/filters.rb |