用一个wxHandler处理对应的用户请求
512502
public static View handle(WxHandler wxHandler, HttpServletRequest req, String key)
            throws IOException {
        if (wxHandler == null) {
            log.info("WxHandler is NULL");
            return HttpStatusView.HTTP_502;
        }
        String signature = req.getParameter("signature");
        String timestamp = req.getParameter("timestamp");
        String nonce = req.getParameter("nonce");
        String msg_signature = req.getParameter("msg_signature");
        String encrypt_type = req.getParameter("encrypt_type");
        if (!wxHandler.check(signature, timestamp, nonce, key)) {
            log.info("token is invalid");
            return HttpStatusView.HTTP_502;
        }
        if ("GET".equalsIgnoreCase(req.getMethod())) {
            String echostr = req.getParameter("echostr");
            log.info("GET? return echostr=" + echostr);
            return new ViewWrapper(new RawView(null), echostr);
        }
        String postData = Streams.readAndClose(new InputStreamReader(req.getInputStream(),
                                                                     Encoding.CHARSET_UTF8));

        if ("aes".equals(encrypt_type)) {
            WXBizMsgCrypt msgCrypt = wxHandler.getMsgCrypt();
            try {
                // 若抛出Illegal key size,请更新JDK的加密库为不限制长度
                postData = msgCrypt.decryptMsg(msg_signature, timestamp, nonce, postData);
            }
            catch (AesException e) {
                return new HttpStatusView(403);
            }
        }
        WxInMsg in = Wxs.convert(postData);
        in.setExtkey(key);
        WxOutMsg out = wxHandler.handle(in);
        if (out != null) {
            Wxs.fix(in, out);
        }
        return new ViewWrapper(WxView.me, out);
    }
890142
function myMiddleware() {
	return handler => async ctx => {
		ctx.broker.logger.warn(">> MW1-before (from config)");
		const res = await handler(ctx);
		ctx.broker.logger.warn("<< MW1-after (from config)");
		return res;
	};
}
144648
public WxMpMessageRouterRule handler(WxMpMessageHandler handler, WxMpMessageHandler... otherHandlers) {
    this.handlers.add(handler);
    if (otherHandlers != null && otherHandlers.length > 0) {
      for (WxMpMessageHandler i : otherHandlers) {
        this.handlers.add(i);
      }
    }
    return this;
  }
1223428
def menu_callback(self, m):
        ''''''
        if m.returnkey.startswith('# '):
            cmd = m.returnkey[2:]
            if m.handler is not None:
                if m.handler_result is None:
                    return
                cmd += m.handler_result
            self.mpstate.functions.process_stdin(cmd)
        if m.returnkey == 'menuSettings':
            wxsettings.WXSettings(self.settings)
76879
function genWeexHandler (params, handlerCode) {
  var innerHandlerCode = handlerCode;
  var exps = params.filter(function (exp) { return simplePathRE.test(exp) && exp !== '$event'; });
  var bindings = exps.map(function (exp) { return ({ '@binding': exp }); });
  var args = exps.map(function (exp, i) {
    var key = "$_" + (i + 1);
    innerHandlerCode = innerHandlerCode.replace(exp, key);
    return key
  });
  args.push('$event');
  return '{\n' +
    "handler:function(" + (args.join(',')) + "){" + innerHandlerCode + "},\n" +
    "params:" + (JSON.stringify(bindings)) + "\n" +
    '}'
}
530536
def call(self):
        ''''''
        from wx_loader import wx

        # remap flags to wx descriptors
        flag_map = {
            'open': wx.FD_OPEN,
            'save': wx.FD_SAVE,
            'overwrite_prompt': wx.FD_OVERWRITE_PROMPT,
        }
        flags = map(lambda x: flag_map[x], self.flags)

        dlg = wx.FileDialog(None, self.title, '', "", self.wildcard, flags)
        if dlg.ShowModal() != wx.ID_OK:
            return None
        return dlg.GetPath()
1159281
function(_event, _selector, _handler){
            _selector = $._cleanSelector(_selector);
            return this._$forEach(function(_node){
                var _uid = $._$uid(_node),
                    _handlers = $._delegateHandlers[_uid] || ($._delegateHandlers[_uid] = {}),
                    _events = _handlers[_event] || (_handlers[_event] = {}),
                    _selectors = _events[_selector] || (_events[_selector] = []);

                var _realCb = function(_e) {//正式回调
                    var _trigger;
                    if (_trigger = _bubbleUp(_selector, _e.target || _e.srcElement , _node)) {
                        _handler.apply(_trigger, arguments);
                    }
                };
                // 保存引用 以可以正确off
                _realCb._raw = _handler;
                _selectors.push(_realCb);
                // 假如不存在对应的容器，则先创建
                _v._$addEvent(_node, _event, _realCb);
                // Fix: 我们保存原始_handler为了 nej的 delEvent可以正确解绑
                // 省去再存储一份handler列表的开销
            });
        }
605334
@Override
	protected final void initChannel(Channel ch) throws Exception {
		ChannelPipeline pipeline=ch.pipeline();
		if (sslCtx != null) {
			pipeline.addLast(sslCtx.newHandler(ch.alloc(),host,port));
        }
		pipeline.addLast(new HttpClientCodec());
		pipeline.addLast(new ChunkedWriteHandler());
		pipeline.addLast(new HttpObjectAggregator(64*1024));
		pipeline.addLast(new WebSocketClientProtocolHandler(WebSocketClientHandshakerFactory.newHandshaker(webSocketURL, WebSocketVersion.V13, subprotocol, false, new DefaultHttpHeaders())));
        pipeline.addLast(new WebSocketConnectedClientHandler());//连接成功监听handler
	}
980789
def _get_handlers(self):
        
        # 查找所有 Handler。
        members = {}
        for d in __conf__.ACTION_DIR_NAME:
            members.update(get_members(d,
                           None,
                           lambda m: isclass(m) and issubclass(m, BaseHandler) and hasattr(m, "__urls__") and m.__urls__))

        # 分解 __urls__ 配置。
        handlers = [(pattern, order, h) for h in members.values() for pattern, order in h.__urls__]

        # 排序。
        # handlers.sort(cmp = cmp, key = lambda x: x[1])

        try:
            api_version = __conf__.API_VERSION
        except Exception as e:
            api_version = ''

        handlers = [(api_version + pattern, handler) for pattern, _, handler in handlers]

        handlers.append((r'^/(.*?)$', tornado.web.StaticFileHandler, {"path":"static", "default_filename":"index.html"}))
        return handlers
23103
async def handler(self):
    ''''''
    self.ws = await websockets.connect(self.url, ssl=self.ssl)
    while self.ws:
      message = await self.ws.recv()
      for handle in self.on_message:
        if asyncio.iscoroutinefunction(handle):
          await handle(self, message)
        else:
          handle(self, message)
211134
def login(self, user, password, exe_path, comm_password=None, **kwargs):
        
        try:
            self._app = pywinauto.Application().connect(
                path=self._run_exe_path(exe_path), timeout=1
            )
        # pylint: disable=broad-except
        except Exception:
            self._app = pywinauto.Application().start(exe_path)
            is_xiadan = True if "xiadan.exe" in exe_path else False
            # wait login window ready
            while True:
                try:
                    self._app.top_window().Edit1.wait("ready")
                    break
                except RuntimeError:
                    pass

            self._app.top_window().Edit1.type_keys(user)
            self._app.top_window().Edit2.type_keys(password)
            while True:
                self._app.top_window().Edit3.type_keys(
                    self._handle_verify_code(is_xiadan)
                )
                self._app.top_window()["确定" if is_xiadan else "登录"].click()

                # detect login is success or not
                try:
                    self._app.top_window().wait_not("exists visible", 10)
                    break
                # pylint: disable=broad-except
                except Exception:
                    if is_xiadan:
                        self._app.top_window()["确定"].click()

            self._app = pywinauto.Application().connect(
                path=self._run_exe_path(exe_path), timeout=10
            )
        self._close_prompt_windows()
        self._main = self._app.window(title="网上股票交易系统5.0")
        try:
            self._main.child_window(
                control_id=129, class_name="SysTreeView32"
            ).wait("ready", 2)
        # pylint: disable=broad-except
        except Exception:
            self.wait(2)
            self._switch_window_to_normal_mode()
440329
protected ChannelHandler initLogHandlerAdapter(ChannelHandler init)
	{
		ChannelHandler handler=new  ShareableChannelInboundHandler() {
			@Override
			public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
				Channel ch=ctx.channel();
				manageChannel(ch);
				LogLevel level=config.getChannelLevel();
				if(level!=null)
				{//单个链路的日志记录器
					ch.pipeline().addLast(new LoggerHandler(level));
				}
				ch.pipeline().addLast(init);
				ctx.pipeline().remove(this);//移除当前handler
				ctx.fireChannelRegistered();//从当前handler往后抛出事件
			}
		};
//		ChannelHandler handler=new ChannelInitializer<Channel>() {
//			@Override
//			protected void initChannel(Channel ch) throws Exception {
//				channelGroup.add(ch);
//				LogLevel level=config.getLevel();
//				if(level!=null)
//				{
//					ch.pipeline().addLast(new LoggerHandler(config.getLevel()));
//				}
//				ch.pipeline().addLast(init);
//			}
//		};
		return handler;
	}
375413
function notifyHandlers (stack, windowError) {
            var exception = null;
            if (windowError && !TraceKit.collectWindowErrors) {
                return;
            }
            for (var i in handlers) {
                if (_has(handlers, i)) {
                    try {
                        handlers[i].apply(null, [stack].concat(_slice.call(arguments, 2)));
                    } catch (inner) {
                        exception = inner;
                    }
                }
            }

            if (exception) {
                throw exception;
            }
        }
1109373
function initDomHandler(instance) {
    zrUtil.each(touchHandlerNames, function (name) {
        instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
    });

    zrUtil.each(pointerHandlerNames, function (name) {
        instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
    });

    zrUtil.each(mouseHandlerNames, function (name) {
        instance._handlers[name] = makeMouseHandler(domHandlers[name], instance);
    });

    function makeMouseHandler(fn, instance) {
        return function () {
            if (instance._touching) {
                return;
            }
            return fn.apply(instance, arguments);
        };
    }
}
631308
private void installLexicalHandler ()
    {
        XMLReader parent = getParent();
        if (parent == null) {
            throw new NullPointerException("No parent for filter");
        }
        // try to register for lexical events
        for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) {
            try {
                parent.setProperty(LEXICAL_HANDLER_NAMES[i], this);
                break;
            }
            catch (SAXNotRecognizedException ex) {
                // ignore
            }
            catch (SAXNotSupportedException ex) {
                // ignore
            }
        }
    }
698094
public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
    int retryTimes = 0;
    do {
      try {
        return executeInternal(executor, uri, data);
      } catch (WxErrorException e) {
        WxError error = e.getError();
        /**
         * -1 系统繁忙, 1000ms后重试
         */
        if (error.getErrorCode() == -1) {
          int sleepMillis = retrySleepMillis * (1 << retryTimes);
          try {
            log.debug("微信系统繁忙，{}ms 后重试(第{}次)", sleepMillis, retryTimes + 1);
            Thread.sleep(sleepMillis);
          } catch (InterruptedException e1) {
            throw new RuntimeException(e1);
          }
        } else {
          throw e;
        }
      }
    } while (++retryTimes < maxRetryTimes);

    throw new RuntimeException("微信服务端异常，超出重试次数");
  }
153782
async function handle(sofar) {
    //根据路由执行相关操作
    try{
        let rs = await sofar.facade.callFunc(sofar.msg.control, sofar.msg.func, sofar.socket.user, sofar.msg);
        sofar.fn(rs);
    }catch(e){
        sofar.fn({code: facade.const.ReturnCode.Error});

        console.error(e);
    }
}