Module: Apphunk::Proxy
- Defined in:
- lib/apphunk/proxy.rb
Constant Summary collapse
- PROXY_API_URL =
"http://127.0.0.1:8212/api/messages"
Class Method Summary collapse
- .prepare_payload(message, options) ⇒ Object
- .process_response(result) ⇒ Object
- .send_message_to_apphunkd(message, options) ⇒ Object
Class Method Details
.prepare_payload(message, options) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/apphunk/proxy.rb', line 20 def prepare_payload(, ) { :message => , :token => [:token], :environment => [:environment], :tags => [:tags], :trails => ([:trails].to_json if [:trails]) } end |
.process_response(result) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/apphunk/proxy.rb', line 30 def process_response(result) if result.status == :ok if result.response.code == '201' return true else Apphunk::Logger.error "The Apphunkd-Proxy couldn't store the message: #{result.response.code} / #{result.response.body}" return false end else Apphunk::Logger.error "Connection Error: Could not get a response from local Apphunkd-Proxy in time" return false end end |
.send_message_to_apphunkd(message, options) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/apphunk/proxy.rb', line 10 def (, ) if [:environments] && [:environment] && ![:environments].include?([:environment]) return false end payload = prepare_payload(, ) result = Apphunk::Remote.post(PROXY_API_URL, payload, 3) return process_response(result) end |