Sha256: 8256a28083b1639c8da1b4eaed69493ce76dd3c23a46696116ad5f7a0739fc7e

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)
          server.run
          puts "serving at #{url}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pytty-0.5.0 lib/pytty/daemon/api/server.rb
pytty-0.4.1 lib/pytty/daemon/api/server.rb