mamantoha / http_proxy

A HTTP Proxy server and client written in Crystal
MIT License
39 stars 6 forks source link

incompatible with kemal #7

Closed kostya closed 6 years ago

kostya commented 6 years ago
require "http_proxy"
require "kemal"

spawn do
  server = HTTP::Proxy::Server.new("127.0.0.1", 8080)

  puts "Listening on http://#{server.host}:#{server.port}"
  server.listen
end

Kemal.run
Error in 1.cr:11: instantiating 'Kemal:Module#run()'

Kemal.run
      ^~~

in lib/kemal/src/kemal.cr:19: instantiating 'Kemal:Module#run(Nil)'

    self.run(nil)
         ^~~

in lib/kemal/src/kemal.cr:12: instantiating 'Kemal:Module#run(Nil)'

    self.run port do
         ^~~

in lib/kemal/src/kemal.cr:62: instantiating 'HTTP::Server:Class#new(String, Int32, Array(HTTP::Handler))'

require "http_proxy"
    config.server ||= HTTP::Server.new(config.host_binding, config.port, config.handlers)
                                   ^~~

in /usr/local/Cellar/crystal-lang/0.24.2_1/src/http/server.cr:125: instantiating 'HTTP::Server:Class#build_middleware(Array(HTTP::Handler))'

    handler = HTTP::Server.build_middleware handlers
                           ^~~~~~~~~~~~~~~~

in /usr/local/Cellar/crystal-lang/0.24.2_1/src/http/server.cr:196: instantiating 'HTTP::Handler#next=(HTTP::Handler)'

    0.upto(handlers.size - 2) { |i| handlers[i].next = handlers[i + 1] }
                                                ^~~~

in /usr/local/Cellar/crystal-lang/0.24.2_1/src/http/server/handler.cr:18: expanding macro

  property next : Handler | Proc | Nil
  ^

in macro 'property' expanded macro: macro_4380348752:567, line 10:

   1.
   2.
   3.
   4.             @next : Handler | Proc | Nil
   5.
   6.             def next : Handler | Proc | Nil
   7.               @next
   8.             end
   9.
> 10.             def next=(@next : Handler | Proc | Nil)
  11.             end
  12.
  13.
  14.
  15.

instance variable '@next' of HTTP::Proxy::Server::Handler must be (HTTP::Proxy::Server::Handler | Proc(HTTP::Proxy::Server::Context, Nil) | Nil), not HTTP::Handler
mamantoha commented 6 years ago

Thanks. This should be fixed in v0.3.2.

kostya commented 6 years ago

thanks, now it compiled