Skip to content

Commit 2e34e8b

Browse files
committed
Rename text event => strucuture event.
1 parent 7cb1d88 commit 2e34e8b

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

examples/README.md

-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@
33
* [`cloud_run_http`](./cloud_run_http/) - Deploying an HTTP function to [Cloud Run](http://cloud.google.com/run) with the Functions Framework
44
* [`cloud_run_event`](./cloud_run_event/) - Deploying a [Google Cloud Functions Event](https://cloud.google.com/functions/docs/concepts/events-triggers#events) function to [Cloud Run](http://cloud.google.com/run) with the Functions Framework
55
* [`cloud_run_cloudevents`](./cloud_run_cloudevents/) - Deploying a [CloudEvent](https://github.com/cloudevents/sdk-python) function to [Cloud Run](http://cloud.google.com/run) with the Functions Framework
6-
7-
8-

src/functions_framework/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
class _EventType(enum.Enum):
4545
LEGACY = 1
4646
CLOUDEVENT_BINARY = 2
47-
CLOUDEVENT_TEXT = 3
47+
CLOUDEVENT_STRUCTURED = 3
4848

4949

5050
class _Event(object):
@@ -103,7 +103,7 @@ def _run_binary_cloudevent(function, request, cloudevent_def):
103103
function(event)
104104

105105

106-
def _run_text_cloudevent(function, request, cloudevent_def):
106+
def _run_structured_cloudevent(function, request, cloudevent_def):
107107
data = io.StringIO(request.get_data(as_text=True))
108108
m = cloudevents.sdk.marshaller.NewDefaultHTTPMarshaller()
109109
event = m.FromRequest(cloudevent_def, request.headers, data, json.loads)
@@ -119,7 +119,7 @@ def _get_event_type(request):
119119
):
120120
return _EventType.CLOUDEVENT_BINARY
121121
elif request.headers.get("Content-Type") == "application/cloudevents+json":
122-
return _EventType.CLOUDEVENT_TEXT
122+
return _EventType.CLOUDEVENT_STRUCTURED
123123
else:
124124
return _EventType.LEGACY
125125

@@ -146,8 +146,8 @@ def _cloudevent_view_func_wrapper(function, request):
146146
def view_func(path):
147147
cloudevent_def = _get_cloudevent_version()
148148
event_type = _get_event_type(request)
149-
if event_type == _EventType.CLOUDEVENT_TEXT:
150-
_run_text_cloudevent(function, request, cloudevent_def)
149+
if event_type == _EventType.CLOUDEVENT_STRUCTURED:
150+
_run_structured_cloudevent(function, request, cloudevent_def)
151151
elif event_type == _EventType.CLOUDEVENT_BINARY:
152152
_run_binary_cloudevent(function, request, cloudevent_def)
153153
else:

0 commit comments

Comments
 (0)