File tree Expand file tree Collapse file tree
examples/docker-compose/redis/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ from fastapi import Request
12from opa import get_instance , get_router
23
34router = get_router ()
@@ -23,12 +24,18 @@ def check_bloom_filter(string: str):
2324
2425
2526@router .post ("/bloom" )
26- def add_bloom_filter (string : str ):
27+ async def add_bloom_filter (request : Request , string : str = None ):
2728 # Waiting for https://github.com/tiangolo/fastapi/issues/1018 to have plain/text input
2829 # Possible now, but not with generation of the openapi spec..
2930 walrus = get_instance ('walrus' )
3031 bf = walrus .bloom_filter ('bf' )
31- for i in string .split (' ' ):
32- bf .add (i )
3332
34- return f'Added entries'
33+ if string is None :
34+ async for chunk in request .stream ():
35+ for i in chunk .split ():
36+ bf .add (i )
37+ else :
38+ for i in string .split ():
39+ bf .add (i )
40+
41+ return 'Added entries'
You can’t perform that action at this time.
0 commit comments