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) ⇒ FunctionsFramework::CloudEvents::Event?
Decode an event from the given Rack environment hash.
Instance Method Details
#decode_rack_env(env) ⇒ FunctionsFramework::CloudEvents::Event?
Decode an event from the given Rack environment hash.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/functions_framework/legacy_event_converter.rb', line 30 def decode_rack_env env content_type = CloudEvents::ContentType.new env["CONTENT_TYPE"] return nil unless content_type.media_type == "application" && content_type.subtype_prefix == "json" input = read_input_json env["rack.input"], content_type.charset return nil unless input raw_context = input["context"] || input context = normalized_context raw_context return nil unless context construct_cloud_event context, input["data"] end |