File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -237,16 +237,19 @@ def handle_fiware_action(action)
237
237
http = Net ::HTTP . new ( uri . host , uri . port )
238
238
http . use_ssl = ( uri . scheme == 'https' )
239
239
240
+ headers = {
241
+ 'Authorization' => "Bearer #{ @fiware_broker_auth_token } "
242
+ }
243
+
244
+ headers [ 'Content-Type' ] = 'application/json' if action == 'publish'
245
+ headers [ 'Fiware-Service' ] = @subscription_template . fiware_service if @subscription_template . fiware_service . present?
246
+ headers [ 'Fiware-ServicePath' ] = @subscription_template . fiware_servicepath if @subscription_template . fiware_servicepath . present?
247
+
240
248
request = case action
241
249
when 'publish'
242
- Net ::HTTP ::Post . new ( uri . path , initheader = {
243
- 'Content-Type' => 'application/json' ,
244
- 'Authorization' => "Bearer #{ @fiware_broker_auth_token } "
245
- } ) . tap { |req | req . body = @json_payload }
250
+ Net ::HTTP ::Post . new ( uri . path , headers ) . tap { |req | req . body = @json_payload }
246
251
when 'unpublish'
247
- Net ::HTTP ::Delete . new ( uri . path , initheader = {
248
- 'Authorization' => "Bearer #{ @fiware_broker_auth_token } "
249
- } )
252
+ Net ::HTTP ::Delete . new ( uri . path , headers )
250
253
else
251
254
Rails . logger . error "Unknown action: #{ action } "
252
255
@error_message = l ( :general_action_error )
You can’t perform that action at this time.
0 commit comments