#NEWLINE# def endpoint( path , methods , name = None , **attrs ) : #NEWLINE# #INDENT# 'Decorator function, which turn handler into MethodBasedView class.\n\n    :param path: URL, used for get access to APIs.\n    :param methods: acceptable method name or list of methods.\n    :param name: short name of endpoint.\n    :param attrs: any other attributes, which must be initialized.\n    ' #NEWLINE# def endpoint_decorator( func ) : #NEWLINE# #INDENT# def wrapper( ) : #NEWLINE# #INDENT# class FunctionView ( MethodBasedView ) : #NEWLINE# #INDENT# def handler( self , request , * args , **kwargs ) : #NEWLINE# #INDENT# return func ( request , * args , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# view = FunctionView #NEWLINE# supported_methods = methods #NEWLINE# method_validator = MethodValidator ( ) #NEWLINE# method_validator . validate ( supported_methods ) #NEWLINE# if ( type ( supported_methods ) is str ) : #NEWLINE# #INDENT# supported_methods = [ supported_methods ] #NEWLINE# #UNINDENT# for method in supported_methods : #NEWLINE# #INDENT# setattr ( view , method . lower ( ) , view . handler ) #NEWLINE# #UNINDENT# for attr in attrs : #NEWLINE# #INDENT# setattr ( view , str ( attr ) . lower ( ) , attrs [ attr ] ) #NEWLINE# #UNINDENT# return ( path , view , methods , name ) #NEWLINE# #UNINDENT# return wrapper #NEWLINE# #UNINDENT# return endpoint_decorator