Class: Mxrb::RubyApp::Server
- Inherits:
-
Object
- Object
- Mxrb::RubyApp::Server
- Defined in:
- lib/mxrb/ruby_app.rb
Overview
Loopback HTTP server for the generated backend and browser frontend.
Constant Summary collapse
- MAX_BODY_BYTES =
1_048_576- LOOPBACK_HOSTS =
%w[127.0.0.1 ::1 localhost].freeze
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(root, host: '127.0.0.1', port: 9292, logger: nil, environment: nil) ⇒ Server
constructor
A new instance of Server.
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(root, host: '127.0.0.1', port: 9292, logger: nil, environment: nil) ⇒ Server
Returns a new instance of Server.
989 990 991 992 993 994 995 996 997 |
# File 'lib/mxrb/ruby_app.rb', line 989 def initialize(root, host: '127.0.0.1', port: 9292, logger: nil, environment: nil) @host = host.to_s raise ArgumentError, 'the Ruby application server must bind to loopback' unless LOOPBACK_HOSTS.include?(@host) @port = Integer(port) @application = Application.new(root, environment:) @sessions = @application.session_manager @logger = logger end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
987 988 989 |
# File 'lib/mxrb/ruby_app.rb', line 987 def application @application end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
987 988 989 |
# File 'lib/mxrb/ruby_app.rb', line 987 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
987 988 989 |
# File 'lib/mxrb/ruby_app.rb', line 987 def port @port end |
Instance Method Details
#shutdown ⇒ Object
1007 |
# File 'lib/mxrb/ruby_app.rb', line 1007 def shutdown = @server&.shutdown |