This package contains custom middleware to add a shadow backend to a KrakenD proxy pipe. It can be used to mirror proxy requests to a secondary backend, similar to KrakenD's inbuilt shadow functionality (which does not support proxy requests).
To install shadowproxy
from GitHub:
go get -u github.com/kivra/krakend-shadowproxy@<commit hash>
Using the following configuration, an incoming request to KrakenD's /v1/user/123
endpoint is proxied to https://my.backend.com/v2/user/123
, together with a shadow
request to https://other.backend.com/v3/user/123
. The return value of the shadow
request is ignored.
"endpoints": [
{
"endpoint": "/v1/user/{ukey}",
"method": "POST",
"output_encoding": "no-op",
"extra_config": {
"kivra/shadowproxy": {
"host": [ "https://other.backend.com" ],
"url_pattern": "/v3/user/{ukey}",
"method": "POST"
}
},
"backend": [
{
"host": [ "https://my.backend.com" ],
"url_pattern": "/v2/user/{ukey}",
"method": "POST",
"encoding": "no-op"
}
]
}
]
The middleware configuration supports the following parameters.
The host URL(s) of the backend(s) that will receive the shadow request.
The URL pattern used for requests to the shadow backend.
The request method used for requests to the shadow backend (default "GET"
).
Disable host sanitization for prodived host
list (default false
).
The timeout for the request to the shadow backend as a Go
duration, for
example 10s
. Defaults to the endpoint timeout.