lura icon indicating copy to clipboard operation
lura copied to clipboard

Static response with no backend or fake/void backend

Open Gounlaf opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. I would like to use the Static Proxy feature. I'm in the case stated in documentation:

Another example scenario is to create an endpoint pointing to an unfinished backend where its functionality is not in production yet, but your client application needs to go ahead the backend developers and start using the static responses.

The documentation is clear enough (IMO) about the behavior: the static response is merged at the end of the process.

So, I understand that a backend is always required.

Describe the solution you'd like A "void" or "fake" backend would be nice, in order to avoid errors:

  • a real backend will be contacted, and probably return 4XX or 5XX if the endpoint doesn't exist
  • a backend that doesn't exist will produce a tcpdialup error

Configuration used:

{
  "version": 2,
  "extra_config": {
  },
  "output_encoding": "json",
  "name": "api-gateway",
  "port": 8080,
  "endpoints": [
    {
      "endpoint": "/static/response/with/json",
      "method": "GET",
      "output_encoding": "json",
      "extra_config": {
        "github.com/devopsfaith/krakend/proxy": {
          "static": {
            "strategy": "always",
            "data": {
              "wrapped": [
                {
                  "whatever": "data"
                },
                {
                  "whatever": "other data"
                }
              ]
            }
          }
        }
      },
      "backend": []
    }
  ]
}

Response:

krakend-1  | ERROR parsing the configuration file: '/etc/krakend/krakend.json': WARNING: the 'GET /static/response/with/json' endpoint has 0 backends defined! Ignoring
krakend-1 exited with code 255

Gounlaf avatar Oct 28 '21 09:10 Gounlaf

the proposed behavior is hard to check. that's why an endpoint with no backends is always rejected as errored.

one solution if you don't want to generate errors is to consume the /__debug/ endpoint from the gateway and deny the message field.

kpacha avatar Oct 28 '21 11:10 kpacha

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.

github-actions[bot] avatar Feb 23 '23 00:02 github-actions[bot]