def _typed_event_func_wrapper()

in src/functions_framework/__init__.py [0:0]


def _typed_event_func_wrapper(function, request, inputType: Type):
    @execution_id.set_execution_context(request, _enable_execution_id_logging())
    def view_func(path):
        try:
            data = request.get_json()
            input = inputType.from_dict(data)
            response = function(input)
            if response is None:
                return "", 200
            if response.__class__.__module__ == "builtins":
                return response
            _typed_event._validate_return_type(response)
            return json.dumps(response.to_dict())
        except Exception as e:
            raise FunctionsFrameworkException(
                "Function execution failed with the error"
            ) from e

    return view_func