如何在验证之前记录 POST 请求数据


How to log the POST request data before the validation?

有没有办法在通过 Restler 实现数据验证阶段之前记录收到的 POST 请求数据?

使用 onValidate 事件,它在验证开始之前触发

//in your index.php after $r = new Restler()
$r->onValidate(function() use ($r){
    Logger::log($r->getRequestData());
}

将它们复制到变量中,并验证变量中的值:'

$my_post = $_POST;
//consider we want to validate some query-parameter called q
if(isset($my_post['q']) && ! empty($my_post['p'])) {
    //do something
}