Class: Webmachine::Adapters::Hatetepe

Inherits:
Webmachine::Adapter show all
Defined in:
lib/webmachine/adapters/hatetepe.rb

Defined Under Namespace

Classes: Body

Instance Attribute Summary

Attributes inherited from Webmachine::Adapter

#application

Instance Method Summary collapse

Methods inherited from Webmachine::Adapter

#initialize, run

Constructor Details

This class inherits a constructor from Webmachine::Adapter

Instance Method Details

#call(request, &respond) ⇒ Object


41
42
43
44
45
46
# File 'lib/webmachine/adapters/hatetepe.rb', line 41

def call(request, &respond)
  response = Webmachine::Response.new
  application.dispatcher.dispatch(convert_request(request), response)

  respond.call(convert_response(response))
end

#optionsObject


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/webmachine/adapters/hatetepe.rb', line 17

def options
  {
    :host => application.configuration.ip,
    :port => application.configuration.port,
    :app  => [
      ::Hatetepe::Server::Pipeline,
      ::Hatetepe::Server::KeepAlive,
      method(:call)
    ]
  }
end

#runObject


29
30
31
32
33
34
35
# File 'lib/webmachine/adapters/hatetepe.rb', line 29

def run
  EM.epoll
  EM.synchrony do
    ::Hatetepe::Server.start(options)
    trap("INT") { shutdown }
  end
end

#shutdownObject


37
38
39
# File 'lib/webmachine/adapters/hatetepe.rb', line 37

def shutdown
  EM.stop
end