def _endpoint(name, ignore_body=False):
 def decorator(f):
  @wraps(f)
  @structured(inputSchema={}, outputSchema={u'$ref': (u'/endpoints.json#/definitions/' + name)}, schema_store=SCHEMAS, ignore_body=ignore_body)
  def wrapped(*args, **kwargs):
   d = maybeDeferred(f, *args, **kwargs)
   def handle_error(failure):
    if failure.check(BadRequest):
     code = failure.value.code
     body = failure.value.result
    else:
     writeFailure(failure)
     code = OK
     body = {u'Err': u'{}: {}'.format(failure.type.__name__, failure.value)}
    return EndpointResponse(code, body)
   d.addErrback(handle_error)
   return d
  return wrapped
 return decorator

def _endpoint ( name , ignore_body = False ) : def decorator ( f ) : @ wraps ( f ) @ structured ( inputSchema = { } , outputSchema = { u'$ref' : ( u'/endpoints.json#/definitions/' + name ) } , schema_store = SCHEMAS , ignore_body = ignore_body ) def wrapped ( * args , ** kwargs ) : d = maybeDeferred ( f , * args , ** kwargs ) def handle_error ( failure ) : if failure . check ( BadRequest ) : code = failure . value . code body = failure . value . result else : writeFailure ( failure ) code = OK body = { u'Err' : u'{}: {}' . format ( failure . type . __name__ , failure . value ) } return EndpointResponse ( code , body ) d . addErrback ( handle_error ) return d return wrapped return decorator
decorator factory for api endpoints .