luraproject / lura

Ultra performant API Gateway with middlewares. A project hosted at The Linux Foundation
https://luraproject.org
Other
6.35k stars 563 forks source link

Passing a response attribute with Sequential Proxy to the next request (Martian) #392

Closed Bishop19 closed 4 years ago

Bishop19 commented 4 years ago

Hi everyone,

Is there a way to include a response attribute from a previous request (with sequential proxy) in the next request's body? I'm trying to use Martian but I don't know if this is the correct way (or even if it is possible):

      "endpoint": "/auctions",
      "method": "POST",
      "extra_config": {
        "github.com/devopsfaith/krakend/proxy": {
          "sequential": true
        } 
      },
      "output_encoding": "json"
      "backend": [
        {
          "url_pattern": "/v1/auctions-schedule",
          "encoding": "json",
          "method": "POST",
          "disable_host_sanitize": false
        },
        {
          "url_pattern": "/v1/auctions-schedule",
          "encoding": "json",
          "extra_config": {
              "github.com/devopsfaith/krakend-martian": {
                  "body.Modifier": {
                      "scope": ["request"],
                      "body": "{resp_0_my_base64response",
                 }
               }
           },
          "method": "POST",
          "disable_host_sanitize": false
        }
      ]
    }

Another question: is the body passed to the first request also passed to the second?

Thanks in advance!

Note: Currently taking a Masters in Software Engineering and this is my first experience with Krakend, be kind `:D

kpacha commented 4 years ago

yes, you can use elements from previous responses as request params (https://www.krakend.io/docs/endpoints/sequential-proxy/). but you can't use not safe methods (https://tools.ietf.org/html/rfc7231#section-4.2.1) with sequential proxy because it would require setting up a distributed transaction.

github-actions[bot] commented 2 years ago

This issue was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link.