Skip to content

Commit

Permalink
specified param types
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrand committed Sep 6, 2017
1 parent ea739e4 commit 96afdd4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/router/handlers/router.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Router
nil
end

def call(context)
def call(context : HTTP::Server::Context)
if route_context = search_route(context)
route_context.api.call(context, route_context.params)
else
Expand All @@ -46,14 +46,15 @@ module Router
# RouteHandler to be drawn
@tmp_route_handler : RouteHandler?

def draw(route_handler, &block)
def draw(route_handler : RouteHandler?, &block)
@tmp_route_handler = route_handler
yield
@tmp_route_handler = nil
end

# Supported http methods
HTTP_METHODS = %w(get post put patch delete options)

{% for http_method in HTTP_METHODS %}
def {{http_method.id}}(path : String, api : API)
abort "Please call `{{http_method.id}}` in `draw`" if @tmp_route_handler.nil?
Expand Down

0 comments on commit 96afdd4

Please sign in to comment.