path_starts_with... method naming (#310)
Fix name of path_starts_with_... utility method
This commit is contained in:
parent
9607083e59
commit
54e501e964
2 changed files with 3 additions and 3 deletions
|
@ -9,13 +9,13 @@ FILTER_METHODS = %w(get post put patch delete options all)
|
||||||
|
|
||||||
{% for method in HTTP_METHODS %}
|
{% for method in HTTP_METHODS %}
|
||||||
def {{method.id}}(path, &block : HTTP::Server::Context -> _)
|
def {{method.id}}(path, &block : HTTP::Server::Context -> _)
|
||||||
raise Kemal::Exceptions::InvalidPathStartException.new({{method}}, path) unless Kemal::Utils.path_starts_with_backslash?(path)
|
raise Kemal::Exceptions::InvalidPathStartException.new({{method}}, path) unless Kemal::Utils.path_starts_with_slash?(path)
|
||||||
Kemal::RouteHandler::INSTANCE.add_route({{method}}.upcase, path, &block)
|
Kemal::RouteHandler::INSTANCE.add_route({{method}}.upcase, path, &block)
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
def ws(path, &block : HTTP::WebSocket, HTTP::Server::Context -> Void)
|
def ws(path, &block : HTTP::WebSocket, HTTP::Server::Context -> Void)
|
||||||
raise Kemal::Exceptions::InvalidPathStartException.new("ws", path) unless Kemal::Utils.path_starts_with_backslash?(path)
|
raise Kemal::Exceptions::InvalidPathStartException.new("ws", path) unless Kemal::Utils.path_starts_with_slash?(path)
|
||||||
Kemal::WebSocketHandler.new path, &block
|
Kemal::WebSocketHandler.new path, &block
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Kemal
|
module Kemal
|
||||||
module Utils
|
module Utils
|
||||||
def self.path_starts_with_backslash?(path)
|
def self.path_starts_with_slash?(path)
|
||||||
path.starts_with?("/")
|
path.starts_with?("/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue