Feature Request: Add method or class handler
iambudi opened this issue ยท 1 comments
iambudi commented
As addition to use block handler, it would be nice to add method handler or class handler to make the router code cleaner and follow separation of concern.
# block handler
get "/" do |context, params|
context.response.print "Hello router.cr!"
context
end
# method handler
get "/" home
post "/user" add_user
def home(context, params) : HTTP::Server::Context
context.response.print "Hello router.cr!"
context
end
# class handler
article = Article.new
get "/article/:id" article.get
put "/article/:id" article.update
class Article
def get(context, params)
context.response.print "Hello router.cr!"
context
end
end
tbrand commented
Sounds good. ๐
I don't have much time to work on it.
Someone help us or you could send a pull request. ๐