@@ -45,6 +45,7 @@ def __init__(self, func: Callable, script_file: str):
4545 self ._trigger : Optional [Trigger ] = None
4646 self ._bindings : List [Binding ] = []
4747 self .function_script_file = script_file
48+ self .http_type = 'function'
4849
4950 def add_binding (self , binding : Binding ) -> None :
5051 """Add a binding instance to the function.
@@ -85,6 +86,13 @@ def set_function_name(self, function_name: Optional[str] = None) -> None:
8586 if function_name :
8687 self ._name = function_name
8788
89+ def set_http_type (self , http_type : str ) -> None :
90+ """Set or update the http type for the function if :param:`http_type`
91+ .
92+ :param http_type: Http function type.
93+ """
94+ self .http_type = http_type
95+
8896 def get_trigger (self ) -> Optional [Trigger ]:
8997 """Get attached trigger instance of the function.
9098
@@ -158,6 +166,11 @@ def configure_function_name(self, function_name: str) -> 'FunctionBuilder':
158166
159167 return self
160168
169+ def configure_http_type (self , http_type : str ) -> 'FunctionBuilder' :
170+ self ._function .set_http_type (http_type )
171+
172+ return self
173+
161174 def add_trigger (self , trigger : Trigger ) -> 'FunctionBuilder' :
162175 self ._function .add_trigger (trigger = trigger )
163176 return self
@@ -281,6 +294,23 @@ def decorator():
281294
282295 return wrap
283296
297+ def http_type (self , http_type : str ) -> Callable :
298+ """Set http type of the :class:`Function` object.
299+
300+ :param http_type: Http type of the function.
301+ :return: Decorator function.
302+ """
303+
304+ @self ._configure_function_builder
305+ def wrap (fb ):
306+ def decorator ():
307+ fb .configure_http_type (http_type )
308+ return fb
309+
310+ return decorator ()
311+
312+ return wrap
313+
284314
285315class HttpFunctionsAuthLevelMixin (ABC ):
286316 """Interface to extend for enabling function app level http
@@ -1638,7 +1668,8 @@ class ExternalHttpFunctionApp(FunctionRegister, TriggerApi, ABC):
16381668
16391669 def _add_http_app (self ,
16401670 http_middleware : Union [
1641- AsgiMiddleware , WsgiMiddleware ]) -> None :
1671+ AsgiMiddleware , WsgiMiddleware ],
1672+ http_type : str ) -> None :
16421673 """Add a Wsgi or Asgi app integrated http function.
16431674
16441675 :param http_middleware: :class:`AsgiMiddleware` or
@@ -1647,6 +1678,7 @@ def _add_http_app(self,
16471678 :return: None
16481679 """
16491680
1681+ @self .http_type (http_type = http_type )
16501682 @self .route (methods = (method for method in HttpMethod ),
16511683 auth_level = self .auth_level ,
16521684 route = "/{*route}" )
@@ -1662,7 +1694,7 @@ def __init__(self, app,
16621694 :param app: asgi app object.
16631695 """
16641696 super ().__init__ (auth_level = http_auth_level )
1665- self ._add_http_app (AsgiMiddleware (app ))
1697+ self ._add_http_app (AsgiMiddleware (app ), 'asgi' )
16661698
16671699
16681700class WsgiFunctionApp (ExternalHttpFunctionApp ):
@@ -1673,4 +1705,4 @@ def __init__(self, app,
16731705 :param app: wsgi app object.
16741706 """
16751707 super ().__init__ (auth_level = http_auth_level )
1676- self ._add_http_app (WsgiMiddleware (app ))
1708+ self ._add_http_app (WsgiMiddleware (app ), 'wsgi' )
0 commit comments