Skip to content

Commit d8a2a2d

Browse files
authored
Merge pull request #21 from stakach/master
add leading / to Radix::Tree
2 parents 3b29724 + a57099f commit d8a2a2d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/router.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module Router
1212
# Define each method for supported http methods
1313
{% for http_method in HTTP_METHODS %}
1414
def {{http_method.id}}(path : String, &block : Action)
15-
@route_handler.add_route("{{http_method.id.upcase}}" + path, block)
15+
@route_handler.add_route("/{{http_method.id.upcase}}" + path, block)
1616
end
1717
{% end %}
1818
end

src/router/handler/handler.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ module Router
88

99
def search_route(context : HTTP::Server::Context) : RouteContext?
1010
method = context.request.method
11-
route = @tree.find(method.upcase + context.request.path)
11+
route = @tree.find("/" + method.upcase + context.request.path)
1212

13-
return { action: route.payload, params: route.params } if route.found?
13+
return {action: route.payload, params: route.params} if route.found?
1414

1515
nil
1616
end

0 commit comments

Comments
 (0)