Class: Genesis::Http::Server
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Genesis::Http::Server
- Defined in:
- lib/genesis/protocol/http/server.rb
Overview
Implement an HTTP server using async_sinatra and thin
Instance Attribute Summary
Attributes included from Server
Class Method Summary collapse
-
.start_server ⇒ Object
Block to actually start the server.
Instance Method Summary collapse
-
#initialize(app = nil, **kwargs) ⇒ Server
constructor
Inject the channel and extended routes.
Methods included from Protocol
Methods included from Server
Constructor Details
#initialize(app = nil, **kwargs) ⇒ Server
Inject the channel and extended routes
34 35 36 37 38 39 40 |
# File 'lib/genesis/protocol/http/server.rb', line 34 def initialize(app = nil, **kwargs) super(app) @channel = kwargs[:channel] || nil @extended_routes = kwargs[:routes] || {} @views = kwargs[:views] || [] initialize_routes end |
Class Method Details
.start_server ⇒ Object
Block to actually start the server
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/genesis/protocol/http/server.rb', line 18 def self.start_server app = new(channel: @channel, routes: @handle_routes, views: @args[:views] || []) dispatch = Rack::Builder.app do map '/' do run app end end # Enable full request logging with @debug Thin::Logging.trace=true if @args[:debug] # Since Thin is backed by EventMachine's TCPserver anyways, # This is just a TCPServer like any other - running inside the same EventMachine! Thin::Server.new(@port, '0.0.0.0', dispatch).backend.start end |