File tree Expand file tree Collapse file tree 7 files changed +15
-10
lines changed
Expand file tree Collapse file tree 7 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ Create a `Gemfile` listing the Functions Framework as a dependency:
6060``` ruby
6161# Gemfile
6262source " https://rubygems.org"
63- gem " functions_framework" , " ~> 0.10 "
63+ gem " functions_framework" , " ~> 0.11 "
6464```
6565
6666Create a file called ` app.rb ` and include the following code. This defines a
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ Create a `Gemfile` listing the Functions Framework as a dependency:
6464``` ruby
6565# Gemfile
6666source " https://rubygems.org"
67- gem " functions_framework" , " ~> 0.10 "
67+ gem " functions_framework" , " ~> 0.11 "
6868```
6969
7070Create a file called ` app.rb ` and include the following code. This defines a
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ dependency on Sinatra in your `Gemfile`:
111111
112112``` ruby
113113source " https://rubygems.org"
114- gem " functions_framework" , " ~> 0.10 "
114+ gem " functions_framework" , " ~> 0.11 "
115115gem " sinatra" , " ~> 2.0"
116116```
117117
@@ -470,7 +470,7 @@ Following is a typical layout for a Functions Framework based project.
470470``` ruby
471471# Gemfile
472472source " https://rubygems.org"
473- gem " functions_framework" , " ~> 0.10 "
473+ gem " functions_framework" , " ~> 0.11 "
474474```
475475
476476``` ruby
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ version = ::FunctionsFramework::VERSION
4545 spec . executables = [ "functions-framework" , "functions-framework-ruby" ]
4646
4747 spec . required_ruby_version = ">= 2.5.0"
48- spec . add_dependency "cloud_events" , ">= 0.4 " , "< 2.a"
48+ spec . add_dependency "cloud_events" , ">= 0.5.1 " , "< 2.a"
4949 spec . add_dependency "puma" , ">= 4.3.0" , "< 6.a"
5050 spec . add_dependency "rack" , "~> 2.1"
5151
Original file line number Diff line number Diff line change @@ -431,7 +431,7 @@ def call env
431431 when ::CloudEvents ::Event
432432 handle_cloud_event event , logger
433433 when ::Array
434- ::CloudEvents ::HttpContentError . new "Batched CloudEvents are not supported"
434+ ::CloudEvents ::CloudEventsError . new "Batched CloudEvents are not supported"
435435 when ::CloudEvents ::CloudEventsError
436436 event
437437 else
@@ -443,9 +443,13 @@ def call env
443443 private
444444
445445 def decode_event env
446- @cloud_events . decode_rack_env ( env ) ||
446+ begin
447+ @cloud_events . decode_event env
448+ rescue ::CloudEvents ::NotCloudEventError
449+ env [ "rack.input" ] . rewind rescue nil
447450 @legacy_events . decode_rack_env ( env ) ||
448- raise ( ::CloudEvents ::HttpContentError , "Unrecognized event format" )
451+ raise ( ::CloudEvents ::CloudEventsError , "Unrecognized event format" )
452+ end
449453 rescue ::CloudEvents ::CloudEventsError => e
450454 e
451455 end
Original file line number Diff line number Diff line change 1818 end
1919
2020 json_format = CloudEvents ::JsonFormat . new
21- File . write OUTPUT_FILE , json_format . encode ( event )
21+ result = json_format . encode_event event : event
22+ File . write OUTPUT_FILE , result [ :content ]
2223end
Original file line number Diff line number Diff line change 3333 let ( :port ) { 8077 }
3434 let ( :server_url ) { "http://127.0.0.1:#{ port } " }
3535 let ( :quiet_logger ) {
36- logger = ::Logger . new $stdout
36+ logger = ::Logger . new $stderr
3737 logger . level = ::Logger ::FATAL
3838 logger
3939 }
You can’t perform that action at this time.
0 commit comments