don't crash on naive (parameter-less) HTTP request

Denver Gingerich created

This fix is ported in from sgx-catapult, where we made the fix in
https://gitlab.com/ossguy/sgx-catapult/commit/300def9 - it is fairly
simple, but also fairly important.  Here is the description:

Without this fix, one will get the following error (and subsequent
crash) if the port that sgx-catapult is running on receives a naive
HTTP request, such as a "GET /" (from Wget or curl or similar):

  Shutting down gateway due to exception 013: no implicit conversion of nil into String

Change summary

sgx-bwmsgsv2.rb | 5 +++++
1 file changed, 5 insertions(+)

Detailed changes

sgx-bwmsgsv2.rb 🔗

@@ -812,6 +812,11 @@ class WebhookHandler < Goliath::API
 
 		puts 'ENV: ' + env.reject{ |k| k == 'params' }.to_s
 
+		if params.empty?
+			puts 'PARAMS empty!'
+			return [200, {}, "OK"]
+		end
+
 		# TODO: process each message in list, not just first one
 		jparams = params['_json'][0]['message']