Skip to content

Conversation

bzp2010
Copy link
Contributor

@bzp2010 bzp2010 commented Jun 6, 2025

Description

Added filter enhancements to the Admin API, allowing routes and stream routes to be filtered by service_id and upstream_id.

This is mainly used to enhance the APISIX dashboard.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@bzp2010 bzp2010 marked this pull request as ready for review June 6, 2025 09:10
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jun 6, 2025
SkyeYoung
SkyeYoung previously approved these changes Jun 9, 2025
AlinsRan
AlinsRan previously approved these changes Jun 9, 2025
@bzp2010 bzp2010 requested a review from nic-6443 June 9, 2025 06:16
@bzp2010 bzp2010 dismissed stale reviews from AlinsRan and SkyeYoung via f776dfe June 9, 2025 10:33
@bzp2010 bzp2010 requested a review from kayx23 June 9, 2025 12:08
The following example filters routes using `service_id`. Applying multiple filters simultaneously will return results that match all filter conditions.

```shell
curl 'http://127.0.0.1:9180/apisix/admin/routes?filter=service_id%3D1' \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one question: can we adjust to use the format a[b]=c&a[d]=e? It seems more common. https://www.npmjs.com/package/qs

Copy link
Contributor Author

@bzp2010 bzp2010 Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no existing API for parsing query strings for such objects in OpenResty, so it may have to use regular expressions to do so.
I don't want to do that right now. The existing format can be implemented in any language client, it's nothing more than a URI-encoded string.

ngx.log(ngx.ERR, require("cjson").encode(ngx.decode_args("filter%5Bservice_id%5D=a&filter%5Bservice_id%5D=b&b=c&c=c")))
[lua] test.lua:1: {"filter[service_id]":["a","b"],"b":"c","c":"c"}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

It's too complicated to support something like this.

@bzp2010 bzp2010 requested review from SkyeYoung, kayx23 and membphis June 11, 2025 04:18
kayx23
kayx23 previously approved these changes Jun 11, 2025
Copy link
Member

@kayx23 kayx23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs LGTM

SkyeYoung
SkyeYoung previously approved these changes Jun 11, 2025
nic-6443
nic-6443 previously approved these changes Jun 11, 2025
@bzp2010 bzp2010 dismissed stale reviews from nic-6443, SkyeYoung, and kayx23 via 0cac9bf June 11, 2025 06:33
@bzp2010 bzp2010 requested a review from juzhiyuan June 11, 2025 06:34
Copy link
Member

@juzhiyuan juzhiyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bzp2010 bzp2010 requested review from SkyeYoung and nic-6443 June 11, 2025 06:40
@bzp2010 bzp2010 requested review from AlinsRan and kayx23 June 11, 2025 07:11
@bzp2010 bzp2010 merged commit 460c3be into apache:master Jun 11, 2025
36 of 37 checks passed
Crazy-xyr pushed a commit to Crazy-xyr/apisix that referenced this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants