mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Improve namings
This commit is contained in:
parent
30bdcc9759
commit
61caa077b7
5 changed files with 19 additions and 19 deletions
|
@ -10,13 +10,13 @@ FILTER_METHODS = %w(get post put patch delete options all)
|
|||
{% for method in HTTP_METHODS %}
|
||||
def {{method.id}}(path : String, &block : HTTP::Server::Context -> _)
|
||||
raise Kemal::Exceptions::InvalidPathStartException.new({{method}}, path) unless Kemal::Utils.path_starts_with_slash?(path)
|
||||
Kemal::RouteHandler::INSTANCE.add_http_route({{method}}.upcase, path, &block)
|
||||
Kemal::RouteHandler::INSTANCE.add_route({{method}}.upcase, path, &block)
|
||||
end
|
||||
{% end %}
|
||||
|
||||
def ws(path : String, &block : HTTP::WebSocket, HTTP::Server::Context -> Void)
|
||||
raise Kemal::Exceptions::InvalidPathStartException.new("ws", path) unless Kemal::Utils.path_starts_with_slash?(path)
|
||||
Kemal::WebSocketHandler::INSTANCE.add_ws_route path, &block
|
||||
Kemal::WebSocketHandler::INSTANCE.add_route path, &block
|
||||
end
|
||||
|
||||
def error(status_code : Int32, &block : HTTP::Server::Context, Exception -> _)
|
||||
|
|
|
@ -18,7 +18,7 @@ module Kemal
|
|||
|
||||
# Adds a given route to routing tree. As an exception each `GET` route additionaly defines
|
||||
# a corresponding `HEAD` route.
|
||||
def add_http_route(method : String, path : String, &handler : HTTP::Server::Context -> _)
|
||||
def add_route(method : String, path : String, &handler : HTTP::Server::Context -> _)
|
||||
add_to_http_radix_tree method, path, Route.new(method, path, &handler)
|
||||
add_to_http_radix_tree("HEAD", path, Route.new("HEAD", path) { |ctx| "" }) if method == "GET"
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ module Kemal
|
|||
@ws_routes.find "/ws#{path}"
|
||||
end
|
||||
|
||||
def add_ws_route(path : String, &handler : HTTP::WebSocket, HTTP::Server::Context -> Void)
|
||||
def add_route(path : String, &handler : HTTP::WebSocket, HTTP::Server::Context -> Void)
|
||||
add_to_ws_radix_tree path, WebSocket.new(path, &handler)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue