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

Alternative implementation #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Alternative implementation #2

wants to merge 2 commits into from

Conversation

dalf
Copy link
Member

@dalf dalf commented Mar 9, 2024

See searxng/searxng#2981

The documentation is not updated, but the example works:

  • if the code calls install_botdetection(app, redis, ...), the botdetection works as expected
  • if the code does not call this function, the botdetection is fully disabled (no endpoint for the token, no overhead, nothing).

@dalf dalf requested a review from return42 March 9, 2024 11:14
from . import http_accept, http_accept_encoding, http_accept_language, http_connection, http_user_agent, ip_limit


class RequestFilter: # pylint: disable=too-few-public-methods
Copy link
Member

@return42 return42 May 16, 2024

Choose a reason for hiding this comment

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

Just a hint / the naming is a bit misleading: A RouteFilter is a (is of type) RequestFilter while a PredefinedRequestFilter is a list (a enumeration type) of functions (with identical prototype and return type).

  • PredefinedRequestFilter --> FilterMethods (or similar)

To avoid a conflict with searxng/searxng#3462 we should not change it here in this branch / we can do it later / just wanted to leaf a note while I'm in review of this PR.


The prototype of the filter methods in PredefinedRequestFilter is the same as the call function of the RequestFilter

IMO the inheritance RouteFilter(RequestFilter) is not valid / the call methods might have identical prototypes but a route filer is something complete different to a request filter: A RouteFilter is a map of URL routes to RequestFilters

This is not a specialization, the basket full of ducks is not the generalization of a duck.

@dalf dalf requested a review from return42 July 14, 2024 07:05
@return42
Copy link
Member

As described on Matrix: I work on the flask-middleware branch

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

Successfully merging this pull request may close these issues.

2 participants