Decorate a function with a request schema.
498074
def request(schema):
    
    def wrapper(func):
        setattr(func, REQUEST, schema)
        return func
    return wrapper
936228
function decorate(list, method, prop) {
  utils.define(list.items, method, function() {
    var res = list[method].apply(list, arguments);
    return prop ? res[prop] : res;
  });
}
469583
function onRequestSchemaValidation(context, req, reply, next) {
  if (context.matchedAction && context._schemaCompiler) {
    const { schema } = context.matchedAction
    const ret = context._schemaCompiler(schema)(req.payload.pattern)
    if (ret) {
      // promise
      if (typeof ret.then === 'function') {
        // avoid to create a seperate promise
        // eslint-disable-next-line promise/catch-or-return
        ret.then(modifiedPattern => {
          if (modifiedPattern) {
            req.payload.pattern = modifiedPattern
          }
          next()
        }, next)
        return
      }
      if (ret.error) {
        return next(ret.error)
      }
      if (ret.value) {
        req.payload.pattern = ret.value
        return next()
      }
    }
  }
  next()
}
213257
def decorate(self, func, target, *anoop, **kwnoop):
        
        if target:
            self.target = target

        def decorated(decorated_self, *args, **kwargs):
            self.handle_target(
                request=decorated_self.request,
                controller_args=args,
                controller_kwargs=kwargs
            )
            return func(decorated_self, *args, **kwargs)

        return decorated
182093
function( m, opts ) {
        return function( o, cb ) {
            var r = __request.apply( this, arguments );
            m.trigger( "request", m, r, opts );
            return r;
        }
    }
567056
def make_request_validator(request):
    """"""
    verb = request.values.get('verb', '', type=str)
    resumption_token = request.values.get('resumptionToken', None)

    schema = Verbs if resumption_token is None else ResumptionVerbs
    return getattr(schema, verb, OAISchema)(partial=False)
481051
def api(func):
    """"""
    @wraps(func)
    def decorated_function(*args, **kwargs):
        try:
            value = func(*args, **kwargs)
        except BaseException as e:
            value = {
                "status": "failed",
                "error": "Unkonwn error!"
            }
            flask.current_app.logger.error("Unkonwn error: %s" % str(e))
            flask.current_app.logger.exception(e)

        status = 200
        mimetype = 'application/json'
        content = json.dumps(value)
        callback = flask.request.args.get('callback', False)
        if callback:
            content = str(callback) + '(' + content + ')'
            mimetype = 'application/javascript'

        return flask.current_app.response_class(content, status=status, mimetype=mimetype)
    return decorated_function
116978
def wrapper(self, updateParams=None):
		
		def decorator(f):
			_headers = self._getHeaders(updateParams)
			""" flask decorator to include headers """
			@wraps(f)
			def decorated_function(*args, **kwargs):
				resp = make_response(f(*args, **kwargs))
				self._setRespHeader(resp, _headers)
				resp.has_secure_headers = True
				return resp
			return decorated_function
		return decorator
396856
def _compose_func(func, args_func=lambda req_info: [req_info.index]):
    
    return FuncInfo(func=func, args_func=args_func)
1118618
def request_middleware(api=None):
    """"""
    def decorator(middleware_method):
        apply_to_api = hug.API(api) if api else hug.api.from_object(middleware_method)

        class MiddlewareRouter(object):
            __slots__ = ()

            def process_request(self, request, response):
                return middleware_method(request, response)

        apply_to_api.http.add_middleware(MiddlewareRouter())
        return middleware_method
    return decorator
735103
def request(req=None, method=None, requires_response=True):
    """"""
    if req is None:
        return functools.partial(request, method=method,
                                 requires_response=requires_response)

    @functools.wraps(req)
    def wrapper(self, *args, **kwargs):
        if self.lsp_ready:
            params = req(self, *args, **kwargs)
            if params is not None:
                self.emit_request(method, params, requires_response)
    return wrapper
1054129
def returns(schema):
    
    validate = parse(schema).validate

    @decorator
    def validating(func, *args, **kwargs):
        ret = func(*args, **kwargs)
        validate(ret, adapt=False)
        return ret
    return validating
461387
def validate_schema(schema_name):
    """"""
    def decorator(f):
        @wraps(f)
        def wrapper(*args, **kw):
            instance = args[0]
            try:
                instance.validator(instance.schemas[schema_name]).validate(request.get_json())
            except ValidationError, e:
                ret_dict = instance._create_ret_object(instance.FAILURE,
                                                       None, True,
                                                       instance.BAD_SCHEMA,
                                                       e.message)
                instance.logger.error("Invalid Schema", ret_dict)
                return jsonify(ret_dict), 400
            instance.logger.debug("Schema is valid")
            return f(*args, **kw)
        return wrapper
    return decorator
438397
def _schema_from_verb(verb, partial=False):
    """"""
    from .verbs import Verbs
    return getattr(Verbs, verb)(partial=partial)
1267077
def decorate(func, caller, extras=()):
    
    evaldict = dict(_call_=caller, _func_=func)
    es = ''
    for i, extra in enumerate(extras):
        ex = '_e%d_' % i
        evaldict[ex] = extra
        es += ex + ', '
    fun = FunctionMaker.create(
        func, "return _call_(_func_, %s%%(shortsignature)s)" % es,
        evaldict, __wrapped__=func)
    if hasattr(func, '__qualname__'):
        fun.__qualname__ = func.__qualname__
    return fun
991997
function SchemaMoment(key, options) {
		SchemaType.call(this, key, options);

		this.get(function(val, self){
			if(!val){
				return val;
			} else {
				return new Moment(val);
			}
		});
	}
294385
def jsonp(func):
    """"""
    @wraps(func)
    def decorated(*args, **kwargs):
        callback = request.args.get('callback', False)
        if callback:
            data = str(func(*args, **kwargs).data)
            content = str(callback) + '(' + data + ')'
            mimetype = 'application/javascript'
            return current_app.response_class(content, mimetype=mimetype)
        else:
            return func(*args, **kwargs)
    return decorated