def resource(**kwargs):
def inner(function):<EOL><INDENT>name = kwargs.pop('<STR_LIT:name>', None)<EOL>if name is None:<EOL><INDENT>name = utils.dasherize(function.__name__)<EOL><DEDENT>methods = kwargs.pop('<STR_LIT>', None)<EOL>if isinstance(methods, six.string_types):<EOL><INDENT>methods = methods,<EOL><DEDENT>handler = (function, methods)<EOL>if name not in _resources:<EOL><INDENT>_handlers[name] = []<EOL>from armet import resources<EOL>kwargs['<STR_LIT:name>'] = name<EOL>class LightweightResource(resources.Resource):<EOL><INDENT>Meta = type(str('<STR_LIT:Meta>'), (), kwargs)<EOL>def route(self, request, response):<EOL><INDENT>for handler, methods in _handlers[name]:<EOL><INDENT>if methods is None or request.method in methods:<EOL><INDENT>return handler(request, response)<EOL><DEDENT><DEDENT>resources.Resource.route(self)<EOL><DEDENT><DEDENT>_resources[name] = LightweightResource<EOL><DEDENT>_handlers[name].append(handler)<EOL>return _resources[name]<EOL><DEDENT>return inner<EOL>
Wraps the decorated function in a lightweight resource.