-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Labels
Description
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