Need to convert queryParam to header when reaching backend

17 views
Skip to first unread message

Swaroop

unread,
Jun 3, 2024, 6:15:41 AMJun 3
to KrakenD Community
Hi All,
Can anyone help me in acheiving the conversion of queryParam from input to header when reaching backend url.
I have tried with lua script below in green highlighted colour,but still they are going as queryParams

{
    "endpoint": "/api/cat",
    "output_encoding": "no-op",
    "method": "GET",
    "input_query_strings": [
        "*"
    ],
    "input_headers": [
        "User-Agent",
        "Accept",
        "X-Access-Token",
        "Host",
        "X-Tenant-Id",
        "x-start-record",
        "x-batch-size"
    ],
    "extra_config": {
        "modifier/lua-endpoint": {
            "allow_open_libs": true,
           "pre": "local c = ctx.load(); c:headers('x-access-token', string.sub(c:headers('Authorization'),8)); c:headers('x-tenant-id', c:headers('spid')); c:headers('x-start-record', c:query('x-start-record')); c:headers('x-batch-size', c:query('x-batch-size'));"
        }
    },
    "backend": [{
            "encoding": "safejson",
            "method": "GET",
            "sd": "static",
            "url_pattern": "/catlogue",
            "host": [
                "{{ env "HOST" }}"
            ]
        }
    ]
}


Thanks

Regards,
Santhiswaroop Chenchu

Swaroop

unread,
Jun 3, 2024, 6:21:46 AMJun 3
to KrakenD Community, Swaroop
Hi All,
Just to be clear i tried to take 'x-start-record' and 'x-batch-size' from input queryParam and wanted to convert into header at backend by lua middleware but not successful though. Any insights can be helpful and appreciated.

Thanks

Regards,
Santhiswaroop Chenchu
Reply all
Reply to author
Forward
0 new messages