socketry / async-http

MIT License
298 stars 45 forks source link

Example in README does not work #1

Closed splattael closed 6 years ago

splattael commented 6 years ago

Hi,

I'd like try async-http got stuck when running the example from the README:

Example

require 'async/http/server'
require 'async/http/client'
require 'async/reactor'

server_addresses = [
    Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
]

app = lambda do |env|
    [200, {}, ["Hello World"]]
end

server = Async::HTTP::Server.new(server_addresses, app)
client = Async::HTTP::Client.new(server_addresses)

Async::Reactor.run do |task|
    server_task = task.async do
        server.run
    end

    response = client.get("/", {})
    puts response.body

    server_task.stop
end

Error

$ ruby example.rb 
/home/peter/.rvm/gems/ruby-2.4.1@pg/gems/async-http-0.3.1/lib/async/http/server.rb:40:in `accept': undefined method `new' for #<Proc:0x00000001e97b58@example.rb:9 (lambda)> (NoMethodError)
    from /home/peter/.rvm/gems/ruby-2.4.1@pg/gems/async-io-1.0.0/lib/async/io/socket.rb:63:in `block in accept_each'
    from /home/peter/.rvm/gems/ruby-2.4.1@pg/gems/async-1.1.0/lib/async/task.rb:74:in `block in initialize'

Do you have any hints what I did wrong?

Kind regards, Peter

ioquatix commented 6 years ago

Thanks for this bug report. I have fixed the README. My apologies, but the Rack compatible API was moved to https://github.com/socketry/falcon