You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/04 01:55:56 UTC

[GitHub] [apisix] GiftLee commented on issue #2827: request help: fault-injection abort.body Using variables

GiftLee commented on issue #2827:
URL: https://github.com/apache/apisix/issues/2827#issuecomment-738504369


   i think enhance fault-injection ,add function 
   
   like  this 
   ```
   
   function _M.rewrite(conf, ctx)
       core.log.info("plugin rewrite phase, conf: ", core.json.delay_encode(conf))
   
       if conf.delay
          and conf.delay.duration ~= nil
          and sample_hit(conf.delay.percentage)
       then
           sleep(conf.delay.duration)
       end
   
       if conf.abort
          and conf.abort.http_status ~= nil
          and sample_hit(conf.abort.percentage)
       then
           -- core.log.debug("sss1 ", conf.abort.body)
           local body = string.gsub(conf.abort.body, "%$(.-)%$", function (func)  return loadstring(func)() end)
           -- core.log.debug("abortwwwu ", body)
           return conf.abort.http_status, body
       end
   end
   ```
   is good idea ?
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org