mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Fix broken websocket routing :/
This commit is contained in:
parent
d676b559d2
commit
7dd834ad28
3 changed files with 2 additions and 8 deletions
|
@ -12,7 +12,6 @@ module Kemal
|
||||||
Kemal::CLI.new
|
Kemal::CLI.new
|
||||||
config = Kemal.config
|
config = Kemal.config
|
||||||
config.setup
|
config.setup
|
||||||
config.add_handler Kemal::RouteHandler::INSTANCE
|
|
||||||
config.port = port if port
|
config.port = port if port
|
||||||
|
|
||||||
config.server = HTTP::Server.new(config.host_binding, config.port, config.handlers)
|
config.server = HTTP::Server.new(config.host_binding, config.port, config.handlers)
|
||||||
|
|
|
@ -57,7 +57,7 @@ module Kemal
|
||||||
HANDLERS
|
HANDLERS
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_handler(handler : HTTP::Handler)
|
def add_handler(handler : HTTP::Handler | HTTP::WebSocketHandler)
|
||||||
setup
|
setup
|
||||||
HANDLERS.insert @custom_handler_position, handler
|
HANDLERS.insert @custom_handler_position, handler
|
||||||
@custom_handler_position = @custom_handler_position + 1
|
@custom_handler_position = @custom_handler_position + 1
|
||||||
|
@ -68,11 +68,6 @@ module Kemal
|
||||||
HANDLERS.insert HANDLERS.size - 1, handler
|
HANDLERS.insert HANDLERS.size - 1, handler
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_ws_handler(handler : HTTP::WebSocketHandler)
|
|
||||||
setup
|
|
||||||
HANDLERS << handler
|
|
||||||
end
|
|
||||||
|
|
||||||
def error_handlers
|
def error_handlers
|
||||||
ERROR_HANDLERS
|
ERROR_HANDLERS
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@ module Kemal
|
||||||
# For each WebSocket route a new handler is created and registered to global handlers.
|
# For each WebSocket route a new handler is created and registered to global handlers.
|
||||||
class WebSocketHandler < HTTP::WebSocketHandler
|
class WebSocketHandler < HTTP::WebSocketHandler
|
||||||
def initialize(@path : String, &@proc : HTTP::WebSocket, HTTP::Server::Context -> Void)
|
def initialize(@path : String, &@proc : HTTP::WebSocket, HTTP::Server::Context -> Void)
|
||||||
Kemal.config.add_ws_handler self
|
Kemal.config.add_handler self
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(context)
|
def call(context)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue