最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

admin - Allow custom REST route to return before doing long operation

programmeradmin0浏览0评论

I have a custom REST route that imports a CSV file. Everything works so far, but I get a timeout error because it's a really big CSV and it takes a long time. I want to make my REST route start the import process, then return a response while continuing to import.

register_rest_route('lws-admin/v1', '/customer/import', array(
  'methods' => 'POST',
  'callback' => function($request) {
    // *start really long operation*

    return array(
      'message' => 'import started'
    );
  }
));
发布评论

评论列表(0)

  1. 暂无评论