0
require 'goliath'
require 'em-synchrony'
require 'em-synchrony/em-http'

class UsersSendEmail < Goliath::API
  use Goliath::Rack::Params

  def response(env)
    [200, {}, {response: 'email sent'}]
  end
end

class UsersCreate < Goliath::API
  use Goliath::Rack::Params

  def response(env)

    #this doesn't work
    http = EM::HttpRequest.new('http://localhost', :path => 'send_email').get

    [200, {}, {response: 'create'}]
  end
end

One of my Goliath endpoints is getting very complex, so I decided to cut it up and use http to communicate between them (above is a simple example of the idea). However I'm having trouble communicating between them. Not sure if this is the best idea, so open to suggestions. Thanks!

sent-hil
  • 18,635
  • 16
  • 56
  • 74
  • 1
    It's a perfectly fine idea. That's actually how our APIs at PostRank were done when we created Goliath. High level APIs would proxy requests to lower level services. – dj2 May 11 '12 at 02:23

1 Answers1

1

Forgot to add in the port number. EM::HttpRequest.new('http://localhost:9000', :path => 'send_email').get

In hindsight I feel silly for asking this.

sent-hil
  • 18,635
  • 16
  • 56
  • 74