Class: Garufa::GarufaApp

Inherits:
Goliath::API
  • Object
show all
Defined in:
lib/garufa/garufa_app.rb

Instance Method Summary collapse

Instance Method Details

#options_parser(opts, options) ⇒ Object

Extend goliath options with our own options.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/garufa/garufa_app.rb', line 18

def options_parser(opts, options)

  options[:port] = DEFAULT_PORT

  opts.separator ""
  opts.separator "Pusher options:"

  new_options = {
    app_key: ['--app_key APP_KEY', 'Pusher application key (required)'],
    secret:  ['--secret SECRET',   'Pusher application secret (required)']
  }
  new_options.each do |k, v|
    opts.on(v.first, v.last) { |value| Garufa::Config[k] = value }
  end
end

#response(env) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/garufa/garufa_app.rb', line 34

def response(env)
  if Faye::WebSocket.websocket?(env)
    WebSocket::Server.call(env)
  else
    API::Server.call(env)
  end
end