The Crystal programming language | http://crystal-lang.org | Fund Crystal's development: http://is.gd/X7PRtI | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/
Kemal::Base.get
and an instance method Kemal::Base#get
. Currently, when I call get
from inside a instance method, it calls the macro, but I would expect it to call the instance method. And it's ugly if you have to invoke the instance method with explicit receiver...
class MyApp < Kemal::Application
get "/" do |env|
"hello"
end
end
MyApp.run
class MyApp < Kemal::Application
get "/" do |env|
"hello"
end
# `instance_routes` could be a macro that will define the `initialize_instance_routes` method
instance_routes do # Here using `with .. yield`, the instance routes can be configured with another DSL (could be methods, .. whatever)
get "/foo" do |env|
"bar"
end
end
end
app = MyApp.new
app.initialize_instance_routes
app.run
get
method would actually call route_handler.add_route("GET", path, &block)