Fix broken websocket routing :/

This commit is contained in:
sdogruyol 2016-11-02 11:19:48 +03:00
parent d676b559d2
commit 7dd834ad28
3 changed files with 2 additions and 8 deletions

View file

@ -12,7 +12,6 @@ module Kemal
Kemal::CLI.new
config = Kemal.config
config.setup
config.add_handler Kemal::RouteHandler::INSTANCE
config.port = port if port
config.server = HTTP::Server.new(config.host_binding, config.port, config.handlers)

View file

@ -57,7 +57,7 @@ module Kemal
HANDLERS
end
def add_handler(handler : HTTP::Handler)
def add_handler(handler : HTTP::Handler | HTTP::WebSocketHandler)
setup
HANDLERS.insert @custom_handler_position, handler
@custom_handler_position = @custom_handler_position + 1
@ -68,11 +68,6 @@ module Kemal
HANDLERS.insert HANDLERS.size - 1, handler
end
def add_ws_handler(handler : HTTP::WebSocketHandler)
setup
HANDLERS << handler
end
def error_handlers
ERROR_HANDLERS
end

View file

@ -3,7 +3,7 @@ module Kemal
# For each WebSocket route a new handler is created and registered to global handlers.
class WebSocketHandler < HTTP::WebSocketHandler
def initialize(@path : String, &@proc : HTTP::WebSocket, HTTP::Server::Context -> Void)
Kemal.config.add_ws_handler self
Kemal.config.add_handler self
end
def call(context)