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

feat: Add the possibility to manipulate query parameters / search string using proxy-rewrite plugin #11237

Open
markokocic opened this issue May 7, 2024 · 1 comment

Comments

@markokocic
Copy link
Contributor

Description

proxy-rewrite plugin has a possibility to add / remove / set headers to the request. It would be nice if it were possible to add / remove / set url query parameters.

For example, let's say we get a request with the following uri: /path?param1=1&param2=this&param3=that and want to overwrite param1, remove param2, and add param4 before sending the request to the upstream. If proxy-rewrite would have the same options for query params as for headers, we could configure it somethign like this:

 "proxy-rewrite": {
    "uri": "/test/home.html",
    "host": "iresty.com",
    "query-params": {
       "set": {
            "param1": "etwas"
        },
        "add": {
            "param4": "(id=32&name=\"test*\")&age<32",
            "param4" : "it's valid to have more params with the same name"
        },
        "remove":[
            "param2"
        ]
    }

Plugin should take care that complete search sting is properly escaped and encoded. This would come very handy when dealing with ODATA services on the backend that use query-params intensively.

Alternative: theoretically it is possible to manipulate the whole uri, including the search string, using regex_uri, but in the case of multiple parameters that regex can quickly grow very wild and unreliable.

@kayx23
Copy link
Member

kayx23 commented May 20, 2024

Just adding that the plugin currently can add URI parameters by rewriting the whole URI. See example here: https://docs.api7.ai/hub/proxy-rewrite#add-url-parameters

It does not yet support the capability to rewrite each URI parameter individually as @markokocic mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants