diff --git a/src/kemal.cr b/src/kemal.cr index 9720b8d..2241768 100644 --- a/src/kemal.cr +++ b/src/kemal.cr @@ -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) diff --git a/src/kemal/config.cr b/src/kemal/config.cr index 975e211..02bdc47 100644 --- a/src/kemal/config.cr +++ b/src/kemal/config.cr @@ -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 diff --git a/src/kemal/websocket_handler.cr b/src/kemal/websocket_handler.cr index 19b83bb..b3907b0 100644 --- a/src/kemal/websocket_handler.cr +++ b/src/kemal/websocket_handler.cr @@ -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)