Sha256: f25f8a81e859d27e1b0d4d3d85a892053cc5770f501268caad92533ae98014fb

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

require "falcon"
require_relative "router"

module Pytty
  module Daemon
    module Api
      class Server
        def self.run(url:)
          rack_app = Rack::Builder.new do
            map "/v1" do
              run Router.new
            end
          end

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

          endpoint = Async::HTTP::URLEndpoint.parse url
          bound_endpoint = Async::IO::SharedEndpoint.bound(endpoint)

          server = Falcon::Server.new(app, bound_endpoint, endpoint.protocol, endpoint.scheme)
          puts "serving at #{url}"
          server.run
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pytty-0.4.0 lib/pytty/daemon/api/server.rb
pytty-0.3.0 lib/pytty/daemon/api/server.rb