<s> '''<STR_LIT>''' <EOL> from corepost . web import RESTResource , route <EOL> from corepost . enums import Http <EOL> from corepost . filters import IRequestFilter , IResponseFilter <EOL> from zope . interface import implements <EOL> class AddCustomHeaderFilter ( ) : <EOL> """<STR_LIT>""" <EOL> implements ( IRequestFilter ) <EOL> def filterRequest ( self , request ) : <EOL> request . received_headers [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> class Change404to503Filter ( ) : <EOL> """<STR_LIT>""" <EOL> implements ( IResponseFilter ) <EOL> def filterResponse ( self , request , response ) : <EOL> if response . code == <NUM_LIT> : <EOL> response . code = <NUM_LIT> <EOL> class WrapAroundFilter ( ) : <EOL> """<STR_LIT>""" <EOL> implements ( IRequestFilter , IResponseFilter ) <EOL> def filterRequest ( self , request ) : <EOL> del ( request . received_headers [ "<STR_LIT>" ] ) <EOL> request . received_headers [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> def filterResponse ( self , request , response ) : <EOL> response . headers [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> class FilterService ( ) : <EOL> path = "<STR_LIT:/>" <EOL> @ route ( "<STR_LIT:/>" , Http . GET ) <EOL> def root ( self , request , ** kwargs ) : <EOL> return request . received_headers <EOL> def run_filter_app ( ) : <EOL> app = RESTResource ( services = ( FilterService ( ) , ) , filters = ( Change404to503Filter ( ) , AddCustomHeaderFilter ( ) , WrapAroundFilter ( ) , ) ) <EOL> app . run ( <NUM_LIT> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> run_filter_app ( ) </s>
