File tree 2 files changed +10
-2
lines changed
flask_parameter_validation 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change
1
+ import asyncio
2
+ import functools
1
3
import inspect
2
4
import re
3
5
from inspect import signature
@@ -40,7 +42,8 @@ def __call__(self, f):
40
42
}
41
43
fn_list [fsig ] = fdocs
42
44
43
- def nested_func (** kwargs ):
45
+ @functools .wraps (f )
46
+ async def nested_func (** kwargs ):
44
47
# Step 1 - Combine all flask input types to one dict
45
48
json_input = None
46
49
if request .headers .get ("Content-Type" ) is not None :
@@ -78,7 +81,11 @@ def nested_func(**kwargs):
78
81
except Exception as e :
79
82
return self .custom_error_handler (e )
80
83
validated_inputs [expected .name ] = new_input
81
- return f (** validated_inputs )
84
+
85
+ if asyncio .iscoroutinefunction (f ):
86
+ return await f (** validated_inputs )
87
+ else :
88
+ return f (** validated_inputs )
82
89
83
90
nested_func .__name__ = f .__name__
84
91
return nested_func
Original file line number Diff line number Diff line change 28
28
platforms = 'any' ,
29
29
install_requires = [
30
30
'Flask' ,
31
+ 'flask[async]' ,
31
32
'python-dateutil' ,
32
33
],
33
34
classifiers = [
You can’t perform that action at this time.
0 commit comments