You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "singhjoga (via GitHub)" <gi...@apache.org> on 2023/03/09 16:30:46 UTC

[GitHub] [apisix] singhjoga opened a new issue, #9045: help request: body-transformer plugin not getting executed

singhjoga opened a new issue, #9045:
URL: https://github.com/apache/apisix/issues/9045

   ### Description
   
   Hi,
   I am trying to transform the request and response using 'body-transformer' plugin, but it seems to be not executing. I using APISIX 3.2.0 in standalone mode. Below is the route configuration:
   `routes:
     - uri: /auth/realms/KPMS/protocol/openid-connect/token
       plugins:
         body-transformer:
           request:
             template: "{% ngx.req.read_body(); local args, err = ngx.req.get_post_args(); for key, val in pairs(args) do ngx.req.set_header(key, val); end; %}"
         proxy-rewrite:
           uri: /gen_token?key=$http_client_id
           method: "GET"
       upstream:
         type: "roundrobin"
         scheme: "http"
         nodes:
           "127.0.0.1:9080": 1
           
     - uri: /gen_token
       plugins:
         public-api:
           uri: "/apisix/plugin/jwt/sign"`
   
   Here Client-Id header is being set in the request.template from the request body. I tested with 'serverless-pre-function', it works. But I also need to generate custom response, therefore want to use 'body-transformer'.
   
   Any ideas what I am missing here.
   
   ### Environment
   
   - APISIX version (run `apisix version`): 3.2.0
   - Operating system (run `uname -a`): Linux DESKTOP-5O11R9R 5.10.16.3-microsoft-standard-WSL2
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`):
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`): Standalone mode
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`):
   


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

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


[GitHub] [apisix] kingluo commented on issue #9045: help request: body-transformer plugin not getting executed

Posted by "kingluo (via GitHub)" <gi...@apache.org>.
kingluo commented on issue #9045:
URL: https://github.com/apache/apisix/issues/9045#issuecomment-1468247498

   @singhjoga
   > If you do not specify `input_format` and no `Content-Type` header, or body is `nil`, then this plugin will not parse the body before template rendering.
   
   So, you could still do template rendering even if the request body is not JSON or XML.
   
   I see your request template does not contain body template text, so what's your actual issue? header not set? empty body?
   
   BTW, to avoid big body issues, it's recommended to use `require("apisix.core").request.get_body()` to read the body or refer to `_body` in your template.


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] github-actions[bot] commented on issue #9045: help request: body-transformer plugin not getting executed

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #9045:
URL: https://github.com/apache/apisix/issues/9045#issuecomment-1669312049

   Due to lack of the reporter's response this issue has been labeled with "no response". It will be close in 3 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] github-actions[bot] commented on issue #9045: help request: body-transformer plugin not getting executed

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #9045:
URL: https://github.com/apache/apisix/issues/9045#issuecomment-1674493566

   This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] github-actions[bot] closed issue #9045: help request: body-transformer plugin not getting executed

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #9045: help request: body-transformer plugin not getting executed
URL: https://github.com/apache/apisix/issues/9045


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] singhjoga commented on issue #9045: help request: body-transformer plugin not getting executed

Posted by "singhjoga (via GitHub)" <gi...@apache.org>.
singhjoga commented on issue #9045:
URL: https://github.com/apache/apisix/issues/9045#issuecomment-1463299407

   I looked into the plugin code. It looks like currently it supports xml and json content types only. In my case content type is 'x-www-form-urlencoded'.


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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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