fn hook_on()

in src/plugin/plugin_swoole.rs [57:79]


    fn hook_on(&self) -> (Box<BeforeExecuteHook>, Box<AfterExecuteHook>) {
        (
            Box::new(|_, execute_data| {
                validate_num_args(execute_data, 2)?;

                let on = execute_data.get_parameter(0);
                if !on
                    .as_z_str()
                    .and_then(|s| s.to_str().ok())
                    .map(|s| s.to_lowercase() == "request")
                    .unwrap_or_default()
                {
                    return Ok(Box::new(()));
                }

                let closure = execute_data.get_mut_parameter(1);
                Self::hack_callback(closure);

                Ok(Box::new(()))
            }),
            Noop::noop(),
        )
    }