Slide 12
Slide 12 text
callGoRemoteControl = (msg, host, action, callback) ->
baseUrl = "https://#{host}.example.com:9876"
actionUrl = "#{baseUrl}/#{action}"
httpAuthToken = ""
msg.http(baseUrl)
.headers
'Authorization': httpAuthToken
.get() (err, res, body) ->
if err
msg.send "Failed to connect to node: #{err}"
else
msg.send "Executing #{action} on #{host} - this may take some time"
msg.http(actionUrl)
.headers
'Authorization': httpAuthToken
.get() (err, res, body) ->
if callback
callback(host, action, body)
else
message = "Result of #{action} on #{host}:\n"
message += body
msg.send(message)