Module: FunctionsFramework::CloudEvents::BinaryContent
- Defined in:
- lib/functions_framework/cloud_events/binary_content.rb
Overview
A content handler for the binary mode. See https://github.com/cloudevents/spec/blob/master/http-protocol-binding.md
Class Method Summary collapse
-
.decode_rack_env(env, content_type) ⇒ FunctionsFramework::CloudEvents::Event
Decode an event from the given Rack environment.
Class Method Details
.decode_rack_env(env, content_type) ⇒ FunctionsFramework::CloudEvents::Event
Decode an event from the given Rack environment
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/functions_framework/cloud_events/binary_content.rb', line 31 def decode_rack_env env, content_type data = env["rack.input"]&.read spec_version = interpret_header env, "HTTP_CE_SPECVERSION" raise "Unrecognized specversion: #{spec_version}" unless spec_version == "1.0" Event.new \ id: interpret_header(env, "HTTP_CE_ID"), source: interpret_header(env, "HTTP_CE_SOURCE"), type: interpret_header(env, "HTTP_CE_TYPE"), spec_version: spec_version, data: data, data_content_type: content_type, data_schema: interpret_header(env, "HTTP_CE_DATASCHEMA"), subject: interpret_header(env, "HTTP_CE_SUBJECT"), time: interpret_header(env, "HTTP_CE_TIME") end |