Module: Iodine::Rack

Defined in:
lib/rack/handler/iodine.rb,
ext/iodine/iodine_helpers.c

Overview

Rack provides a Rack complient interface (connecting Iodine to Rack) for an HTTP and Websocket Server.

Rack also provides convinient access to the HTTP.listen function, which powers the Rack server.

Defined Under Namespace

Modules: Utils

Constant Summary collapse

IODINE_RACK_LOADED =
true

Class Method Summary collapse

Class Method Details

.addressObject

get/set the HTTP socket binding address. Defaults to ‘nil` (usually best).



119
120
121
# File 'lib/rack/handler/iodine.rb', line 119

def self.address
  @address
end

.address=(val) ⇒ Object

get/set the HTTP socket binding address. Defaults to ‘nil` (usually best).



114
115
116
# File 'lib/rack/handler/iodine.rb', line 114

def self.address=(val)
  @address = val
end

.appObject

get/set the Rack application.



14
15
16
# File 'lib/rack/handler/iodine.rb', line 14

def self.app
  @app
end

.app=(val) ⇒ Object

get/set the Rack application.



9
10
11
# File 'lib/rack/handler/iodine.rb', line 9

def self.app=(val)
  @app = val
end

.logObject

get/set the HTTP logging value (true / false). Defaults to the incoming argumrnts or ‘false`.



95
96
97
# File 'lib/rack/handler/iodine.rb', line 95

def self.log
  @log
end

.log=(val) ⇒ Object

get/set the HTTP logging value (true / false). Defaults to the incoming argumrnts or ‘false`.



90
91
92
# File 'lib/rack/handler/iodine.rb', line 90

def self.log=(val)
  @log = val
end

.max_bodyObject

get/set the maximum HTTP body size for incoming data. Defaults to ~50Mb.



65
66
67
# File 'lib/rack/handler/iodine.rb', line 65

def self.max_body
  @max_body
end

.max_body=(val) ⇒ Object

get/set the maximum HTTP body size for incoming data. Defaults to ~50Mb. 0 values are silently ignored.



60
61
62
# File 'lib/rack/handler/iodine.rb', line 60

def self.max_body=(val)
  @max_body = val
end

.max_body_sizeObject

get/set the maximum HTTP body size for incoming data. Defaults to ~50Mb.



55
56
57
# File 'lib/rack/handler/iodine.rb', line 55

def self.max_body_size
  @max_body
end

.max_body_size=(val) ⇒ Object

get/set the maximum HTTP body size for incoming data. Defaults to ~50Mb. 0 values are silently ignored.



50
51
52
# File 'lib/rack/handler/iodine.rb', line 50

def self.max_body_size=(val)
  @max_body = val
end

.max_msgObject

get/set the maximum Websocket body size for incoming data. Defaults to defaults to ~250KB. 0 values are silently ignored.



85
86
87
# File 'lib/rack/handler/iodine.rb', line 85

def self.max_msg
  @max_msg
end

.max_msg=(val) ⇒ Object

get/set the maximum Websocket body size for incoming data. Defaults to defaults to ~250KB. 0 values are silently ignored.



80
81
82
# File 'lib/rack/handler/iodine.rb', line 80

def self.max_msg=(val)
  @max_msg = val
end

.max_msg_sizeObject

get/set the maximum Websocket body size for incoming data. Defaults to defaults to ~250KB. 0 values are silently ignored.



75
76
77
# File 'lib/rack/handler/iodine.rb', line 75

def self.max_msg_size
  @max_msg
end

.max_msg_size=(val) ⇒ Object

get/set the maximum Websocket body size for incoming data. Defaults to defaults to ~250KB. 0 values are silently ignored.



70
71
72
# File 'lib/rack/handler/iodine.rb', line 70

def self.max_msg_size=(val)
  @max_msg = val
end

.portObject

get/set the HTTP listening port. Defaults to 3000.



107
108
109
# File 'lib/rack/handler/iodine.rb', line 107

def self.port
  @port
end

.port=(val) ⇒ Object

get/set the HTTP listening port. Defaults to 3000.



102
103
104
# File 'lib/rack/handler/iodine.rb', line 102

def self.port=(val)
  @port = val
end

.publicObject

get/set the HTTP public folder property. Defaults to 5.



45
46
47
# File 'lib/rack/handler/iodine.rb', line 45

def self.public
  @public
end

.public=(val) ⇒ Object

get/set the HTTP public folder property. Defaults to 5. Defaults to the incoming argumrnts or ‘nil`.



39
40
41
# File 'lib/rack/handler/iodine.rb', line 39

def self.public=(val)
  @public = val
end

.run(app, options = {}) ⇒ Object

Runs a Rack app, as par the Rack handler requirements.



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/rack/handler/iodine.rb', line 125

def self.run(app, options = {})
  # nested applications... is that a thing?
  if @app && @app != app
    old_app = @app
    @app = proc do |env|
      ret = old_app.call(env)
      ret = app.call(env) if !ret.is_a?(Array) || (ret.is_a?(Array) && ret[0].to_i == 404)
      ret
    end
  else
    @app = app
  end
  @port = options[:Port].to_s if options[:Port]
  @address = options[:Address].to_s if options[:Address]

  # # provide Websocket features using Rack::Websocket
  # Rack.send :remove_const, :Websocket if defined?(Rack::Websocket)
  # Rack.const_set :Websocket, ::Iodine::Websocket

  # start Iodine
  Iodine.start

  # # remove the Websocket features from Rack::Websocket
  # Rack.send :remove_const, :Websocket

  true
end

.timeoutObject

get/set the HTTP connection timeout property. Defaults to 5.



24
25
26
# File 'lib/rack/handler/iodine.rb', line 24

def self.timeout
  @timeout
end

.timeout=(t) ⇒ Object

get/set the HTTP connection timeout property. Defaults to 5. Limited to a maximum of 255. 0 values are silently ignored.



19
20
21
# File 'lib/rack/handler/iodine.rb', line 19

def self.timeout=(t)
  @timeout = t
end

.ws_timeoutObject

get/set the Websocket connection timeout property. Defaults to 40 seconds. Limited to a maximum of 255. 0 values are silently ignored.



34
35
36
# File 'lib/rack/handler/iodine.rb', line 34

def self.ws_timeout
  @ws_timeout
end

.ws_timeout=(t) ⇒ Object

get/set the Websocket connection timeout property. Defaults to 40 seconds. Limited to a maximum of 255. 0 values are silently ignored.



29
30
31
# File 'lib/rack/handler/iodine.rb', line 29

def self.ws_timeout=(t)
  @ws_timeout = t
end