def decorator(f): handler = f if not asyncio.iscoroutinefunction(f): # don't require the @_o decorator *and* the HttpServer decorator handler = _o(f) self.routes[method].append((pattern, handler)) if add_head: self.routes['HEAD'].append((pattern, handler)) return handler
def o(f): oroutine = monocle._o(f) return functools.update_wrapper( lambda *a, **k: cb_to_df(oroutine(*a, **k)), oroutine)
def replacement(req, **kwargs): resp = yield _o(f)(req, **kwargs) yield Return(resp)
def decorator(f): handler = _o(f) self.routes[method].append((pattern, handler)) if add_head: self.routes['HEAD'].append((pattern, handler)) return handler