Skip to content

Feature Request: Add method or class handler #31

@iambudi

Description

@iambudi

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions