Class: FunctionsFramework::LegacyEventConverter
- Inherits:
-
Object
- Object
- FunctionsFramework::LegacyEventConverter
- Defined in:
- lib/functions_framework/legacy_event_converter.rb
Overview
Converter from legacy GCF event formats to CloudEvents.
Instance Method Summary collapse
-
#decode_rack_env(env) ⇒ ::CloudEvents::Event?
Decode an event from the given Rack environment hash.
Instance Method Details
#decode_rack_env(env) ⇒ ::CloudEvents::Event?
Decode an event from the given Rack environment hash.
29 30 31 32 33 34 35 36 37 |
# File 'lib/functions_framework/legacy_event_converter.rb', line 29 def decode_rack_env env content_type = ::CloudEvents::ContentType.new env["CONTENT_TYPE"] return nil unless content_type.media_type == "application" && content_type.subtype_base == "json" input = read_input_json env["rack.input"], content_type.charset return nil unless input context = normalized_context input return nil unless context construct_cloud_event context, input["data"] end |