Skip to content

Instantly share code, notes, and snippets.

@imranismail
Last active January 5, 2022 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imranismail/bf44c1de4b1a255bb470abc151f5a729 to your computer and use it in GitHub Desktop.
Save imranismail/bf44c1de4b1a255bb470abc151f5a729 to your computer and use it in GitHub Desktop.
bff jsonresource param passing

Start BFF container

$ docker run --rm -it -v $(pwd)/config.yml:/srv/config.yml ghcr.io/imranismail/bff:v0.5.0

Send a request using the httpbin anything endpoint

$ curl 'http://localhost:5000/params/1' -H 'access-token: this-is-an-access-token'
{
  "args": {},
  "data": "",
  "files": {},
  "form": {},
  "headers": {
    "Accept": "application/json",
    "Accept-Encoding": "gzip",
    "Access-Token": "this-is-an-access-token",
    "Host": "httpbin.org",
    "User-Agent": "Go-http-client/2.0",
    "X-Amzn-Trace-Id": "Root=1-61d540a1-087b09442af7d5460d966a93"
  },
  "json": null,
  "method": "GET",
  "origin": "202.187.192.96",
  "url": "https://httpbin.org/anything/1"
}
verbosity: 3
modifiers: |
- skip.RoundTrip:
scope: [request]
- method.Filter:
method: GET
modifier:
fifo.Group:
modifiers:
- bff.URLFilter:
scope: [request, response]
path: /params/:param
modifier:
fifo.Group:
modifiers:
- body.MultiFetcher:
scope: [response]
resources:
- body.JSONResource:
method: GET
url: https://httpbin.org/anything/:param
allowedHeaders: ["access-token"]
modifier:
status.Verifier:
scope: [response]
statusCode: 200
- status.Modifier:
scope: [response]
statusCode: 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment