Module: Iodine::Rack

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

Overview

Rack is an Iodine HTTP and Websocket Rack server bundled with Iodine for your convinience.

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).



97
98
99
# File 'lib/rack/handler/iodine.rb', line 97

def self.address
  @address
end

.address=(val) ⇒ Object

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



92
93
94
# File 'lib/rack/handler/iodine.rb', line 92

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

.appObject

get/set the Rack application.



12
13
14
# File 'lib/rack/handler/iodine.rb', line 12

def self.app
  @app
end

.app=(val) ⇒ Object

get/set the Rack application.



7
8
9
# File 'lib/rack/handler/iodine.rb', line 7

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

.logObject

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



73
74
75
# File 'lib/rack/handler/iodine.rb', line 73

def self.log
  @log
end

.log=(val) ⇒ Object

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



68
69
70
# File 'lib/rack/handler/iodine.rb', line 68

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

.max_body_sizeObject

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



53
54
55
# File 'lib/rack/handler/iodine.rb', line 53

def self.max_body_size
  @max_body_size
end

.max_body_size=(val) ⇒ Object

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



48
49
50
# File 'lib/rack/handler/iodine.rb', line 48

def self.max_body_size=(val)
  @max_body_size = 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.



63
64
65
# File 'lib/rack/handler/iodine.rb', line 63

def self.max_msg_size
  @max_msg_size
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.



58
59
60
# File 'lib/rack/handler/iodine.rb', line 58

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

.portObject

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



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

def self.port
  @port
end

.port=(val) ⇒ Object

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



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

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

.publicObject

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



43
44
45
# File 'lib/rack/handler/iodine.rb', line 43

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`.



37
38
39
# File 'lib/rack/handler/iodine.rb', line 37

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

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

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



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/rack/handler/iodine.rb', line 103

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] if options[:Port]
  @port = options[:Address] 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.



22
23
24
# File 'lib/rack/handler/iodine.rb', line 22

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.



17
18
19
# File 'lib/rack/handler/iodine.rb', line 17

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.



32
33
34
# File 'lib/rack/handler/iodine.rb', line 32

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.



27
28
29
# File 'lib/rack/handler/iodine.rb', line 27

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