def directive(apply_globally=False, api=None):
 def decorator(directive_method):
  if apply_globally:
   hug.defaults.directives[underscore(directive_method.__name__)] = directive_method
  else:
   apply_to_api = (hug.API(api) if api else hug.api.from_object(directive_method))
   apply_to_api.add_directive(directive_method)
  directive_method.directive = True
  return directive_method
 return decorator

def directive ( apply_globally = False , api = None ) : def decorator ( directive_method ) : if apply_globally : hug . defaults . directives [ underscore ( directive_method . __name__ ) ] = directive_method else : apply_to_api = ( hug . API ( api ) if api else hug . api . from_object ( directive_method ) ) apply_to_api . add_directive ( directive_method ) directive_method . directive = True return directive_method return decorator
a decorator that registers a single hug directive .