]> git.ipfire.org Git - dbl.git/commitdiff
API: Implement a simple search
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Dec 2025 15:24:54 +0000 (15:24 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 Dec 2025 15:24:54 +0000 (15:24 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/dnsbl/api/__init__.py

index c2bc47438c12c70aafa6a0a4e6f9726b7743b7f2..54479e6168b20129261e48e076e0815ceb6cc6b0 100644 (file)
@@ -50,3 +50,18 @@ def require_api_key(api_key: str = fastapi.Depends(api_key_header)):
 # Import any endpoints
 from . import lists
 from . import reports
+
+# Search
+
+@app.get("/search")
+def search(q: str):
+       """
+               Performs a simple search
+       """
+       # Perform the search
+       results = backend.search(q)
+
+       # Return the result as a mapping of the list slug and a list of matching domain names
+       return {
+               list.slug : set(domain.name for domain in results[list]) for list in results
+       }