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/11/24 01:13:27 UTC

[GitHub] [apisix] GiftLee opened a new issue #2827: request help: fault-injection abort.body Using variables

GiftLee opened a new issue #2827:
URL: https://github.com/apache/apisix/issues/2827


   ### Issue description
   abort.body    
   {"status":"success","time":"$time_local"}
   
   $time_local is nginx variables
   or  Custom variable
   
   
   ok     english is poor 
    
    i want this 
   
   location ~ ^/get_json {
       default_type application/json;
       return 200 '{"status":"success","SERVER_TIME":"$current time"}';
   }
   
   ### Environment
   
   * apisix version 2.0:
   * OS: Centos 7
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2827:
URL: https://github.com/apache/apisix/issues/2827#issuecomment-738890572


   waiting for more response


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #2827:
URL: https://github.com/apache/apisix/issues/2827#issuecomment-733469225


   This is a related issue: [https://github.com/apache/apisix/issues/2511 ](https://github.com/apache/apisix/issues/2511), I think supporting variables are very useful.
   
   If the function of this related issue is realized, I think we can implement it.
   [https://github.com/apache/apisix/issues/2809 ](https://github.com/apache/apisix/issues/2809)
   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
GiftLee edited a comment 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
          
           local body = string.gsub(conf.abort.body, "%$(.-)%$", function (func)  return loadstring(func)() end)
          
           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



[GitHub] [apisix] spacewander closed issue #2827: request help: fault-injection abort.body Using variables

Posted by GitBox <gi...@apache.org>.
spacewander closed issue #2827:
URL: https://github.com/apache/apisix/issues/2827


   


----------------------------------------------------------------
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



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

Posted by GitBox <gi...@apache.org>.
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



[GitHub] [apisix] Firstsawyou removed a comment on issue #2827: request help: fault-injection abort.body Using variables

Posted by GitBox <gi...@apache.org>.
Firstsawyou removed a comment on issue #2827:
URL: https://github.com/apache/apisix/issues/2827#issuecomment-733469225


   This is a related issue: [https://github.com/apache/apisix/issues/2511 ](https://github.com/apache/apisix/issues/2511), I think supporting variables are very useful.
   
   If the function of this related issue is realized, I think we can implement it.
   [https://github.com/apache/apisix/issues/2809 ](https://github.com/apache/apisix/issues/2809)
   


----------------------------------------------------------------
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