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

Allow for creating composite filters #1976

Open
Mis1eader-dev opened this issue Mar 19, 2024 · 0 comments
Open

Allow for creating composite filters #1976

Mis1eader-dev opened this issue Mar 19, 2024 · 0 comments

Comments

@Mis1eader-dev
Copy link
Member

Is your feature request related to a problem? Please describe.
Currently we can define singular filters and add them one by one to controllers, however, this gets frustrating when we have dozens of API endpoints that have a set of 3 or 4 filters repeated in each one. For example:

PATH_ADD(
    "/api/something",
    "LoggedIn",
    "Verified",
    "NotSuspicious",
    HttpMethod::Post
)

Having these 3 filters repeated in multiple endpoints is error-prone in the case something is to be changed, for example we may want to add another filter on top of the 3 that does some other checks on the session, now we must go through each file and add that filter for all of them, and we may forget to add it for one of the API endpoints.

Describe the solution you'd like
Add Composite Filters, they are filters that have names just like normal filters, and they have a list of strings that contain the names of individual filters.
These composite filters can be added onto controllers like normal filters, and the composite filter will add its children into the controller automatically.

Describe alternatives you've considered
Macros, and they are quite ugly:

// A header file

#define API_LOGGED_IN_FILTERS \
    "LoggedIn", \
    "Verified", \
    "NotSuspicious"
// API endpoint file

PATH_ADD(
    "/api/something",
    API_LOGGED_IN_FILTERS,
    HttpMethod::Post
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant