Class: Socky::Server::HTTP
- Inherits:
-
Object
- Object
- Socky::Server::HTTP
- Includes:
- Misc
- Defined in:
- lib/socky/server/http.rb
Defined Under Namespace
Classes: ConnectionError
Constant Summary
- DEFAULT_OPTIONS =
{ :debug => false, :timestamp_deviation => 10 }
Instance Method Summary (collapse)
- - (Object) call(env)
-
- (HTTP) initialize(options = {})
constructor
A new instance of HTTP.
Methods included from Misc
Constructor Details
- (HTTP) initialize(options = {})
A new instance of HTTP
13 14 15 16 |
# File 'lib/socky/server/http.rb', line 13 def initialize( = {}) @options = DEFAULT_OPTIONS.merge() Config.new(@options) end |
Instance Method Details
- (Object) call(env)
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/socky/server/http.rb', line 18 def call(env) request = Rack::Request.new(env.merge('CONTENT_TYPE' => nil)) @params = request.params log("received", @params) @app_name = request.path.split('/').last check_app check_channel check_auth channel = Channel.find_or_create(@app_name, @params['channel']) channel.deliver(nil, Message.new(nil, @params)) [202, {}, ['Event sent']] rescue ConnectionError => e [ e.status, {}, [e.] ] rescue Exception [ 500, {}, ['Unknown error'] ] end |