Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration of global param propagation for sequential merger #960

Merged
merged 5 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ krakend
krakend-alpine
cmd/krakend-integration/krakend-integration
tests/fixtures/krakend.json.final
.vscode
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require (
github.com/krakendio/krakend-usage/v2 v2.0.0
github.com/krakendio/krakend-viper/v2 v2.0.1
github.com/krakendio/krakend-xml/v2 v2.1.0
github.com/luraproject/lura/v2 v2.8.0
github.com/luraproject/lura/v2 v2.9.0
github.com/spf13/cobra v1.8.1
github.com/xeipuuv/gojsonschema v1.2.1-0.20200424115421-065759f9c3d7
golang.org/x/sync v0.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/luraproject/lura/v2 v2.8.0 h1:6Dzf8LZHUKq+5Z/UmwGhjaorNINbFHhqiuVYOccmCPo=
github.com/luraproject/lura/v2 v2.8.0/go.mod h1:2KAK+oKW3aGZNb4ys7Z2LHcoeCrqGlqRSCU7BrHjrbU=
github.com/luraproject/lura/v2 v2.9.0 h1:JeqlrUz0wM4ITVHOtEaFJ5sS6TW25/lTDmMCsQUY44U=
github.com/luraproject/lura/v2 v2.9.0/go.mod h1:pJQDsCSSrE5udlzkLvUnFkdrqeQ+jDO1ZIzsx6jgLtk=
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
Expand Down
58 changes: 58 additions & 0 deletions tests/fixtures/krakend.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"version": 3,
"$schema": "https://krakend.io/schema/krakend.json",
"name": "My lovely gateway",
"port": 8080,
"cache_ttl": "3600s",
Expand Down Expand Up @@ -320,6 +321,63 @@
}
]
},
{
"endpoint": "/sequential/propagate",
"extra_config": {
"proxy": {
"sequential": true,
"sequential_propagated_params": ["resp0_first.foo"]
}
},
"backend": [
{
"url_pattern": "/param_forwarding/1",
"host": [ "http://127.0.0.1:8081" ],
"group": "first",
"allow": [ "foo" ]
},
{
"url_pattern": "/param_forwarding/",
"host": [ "http://127.0.0.1:8081" ],
"group": "second",
"allow": [ "path" ],
"extra_config": {
"modifier/lua-backend": {
"pre": "local req = request.load(); local foo = req:params(\"Resp0_first.foo\"); req:url(req:url() .. foo)"
}
}
}
]
},
{
"endpoint": "/sequential/propagate-full",
"extra_config": {
"proxy": {
"sequential": true,
"sequential_propagated_params": ["resp0"]
}
},
"backend": [
{
"encoding": "no-op",
"url_pattern": "/__debug/",
"host": [ "http://localhost:8080" ]
},
{
"url_pattern": "/param_forwarding/",
"host": [ "http://127.0.0.1:8081" ],
"extra_config": {
"modifier/lua-backend": {
"allow_open_libs": true,
"sources": [
"fixtures/lua/base64.lua"
],
"pre": "local req = request.load(); local m = req:params(\"Resp0\"); req:url(req:url() .. to_base64(m))"
}
}
}
]
},
{
"endpoint": "/sequential/incomplete/{param}",
"extra_config": {
Expand Down
15 changes: 15 additions & 0 deletions tests/fixtures/specs/sequential_3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"in": {
"method": "GET",
"url": "http://localhost:8080/sequential/propagate"
},
"out": {
"status_code": 200,
"body": "{\"first\":{\"foo\":42},\"second\":{\"path\":\"/param_forwarding/42\"}}",
"header": {
"content-type": ["application/json; charset=utf-8"],
"Cache-Control": ["public, max-age=3600"],
"X-Krakend-Completed": ["true"]
}
}
}
15 changes: 15 additions & 0 deletions tests/fixtures/specs/sequential_4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"in": {
"method": "GET",
"url": "http://localhost:8080/sequential/propagate-full"
},
"out": {
"status_code": 200,
"body": "{\"foo\":42,\"headers\":{\"Accept-Encoding\":[\"gzip\"],\"User-Agent\":[\"KrakenD Version 2.8.0\"],\"X-Forwarded-Host\":[\"localhost:8080\"]},\"path\":\"/param_forwarding/eyJtZXNzYWdlIjoicG9uZyJ9\",\"query\":{}}",
"header": {
"content-type": ["application/json; charset=utf-8"],
"Cache-Control": ["public, max-age=3600"],
"X-Krakend-Completed": ["true"]
}
}
}
Loading