Class: Pytty::Daemon::Api::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/pytty/daemon/api/server.rb

Instance Method Summary collapse

Constructor Details

#initializeServer

Returns a new instance of Server.



9
10
# File 'lib/pytty/daemon/api/server.rb', line 9

def initialize
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pytty/daemon/api/server.rb', line 12

def run
  rack_app = Rack::Builder.new do
    #use Rack::CommonLogger

    map "/chunk" do
      run Chunk.new
    end
    map "/v1" do
      run Router.new
    end
  end

  app = Falcon::Server.middleware rack_app, verbose: true

  endpoint = Async::HTTP::URLEndpoint.parse "http://0.0.0.0:1234"
  bound_endpoint = Async::Reactor.run do
    Async::IO::SharedEndpoint.bound(endpoint)
  end.result

  server = Falcon::Server.new(app, bound_endpoint, endpoint.protocol, endpoint.scheme)
  Async::Reactor.run do
    server.run
    puts "serving..."
  end
end