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 38 | # File 'lib/functions_framework/legacy_event_converter.rb', line 29 def decode_rack_env env content_type = ::CloudEvents::ContentType.new env["CONTENT_TYPE"], default_charset: "utf-8" 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 input = convert_raw_pubsub_event input, env if raw_pubsub_payload? input context = normalized_context input return nil unless context construct_cloud_event context, input["data"] end |