Last Updated: February 25, 2016
·
1.042K
· jodosha

Getting started with Lotus::Router

On yesterday I've open sourced Lotus::Router: an HTTP router for Ruby. It's fast, lightweight and compatible with the Rack protocol.

It implements a beautiful DSL.
This example shows how to getting started with it.

require 'lotus/router'

Application = Rack::Builder.new do
  router = Lotus::Router.new do
    get '/', to: ->(env) { [200, {}, ['Hello World']] }, as: :root
  end
  run router
end.to_app

To run it:

rackup application.rb

If you're wondering how to write integration and unit tests, here the complete example: https://gist.github.com/jodosha/8594998