Last month I gave the closing keynote at RubyDay 2015 by talking about Lotus and the future of Ruby.
For the attendees, the most surprising part of my speech was about MRuby. It’s a minimal version of Ruby, that can be embedded in any system that supports C.
I think that this technology can play a key role for Ruby in the next years. The simplicity of the language can be used within complex systems. »
Do you need a fast and lightweight JSON API app? It must be powerful, flexible, quick to develop and easy to deploy?
There is a simple solution for all these requirements: to use Lotus gems to build it.
Lotus is well known for full stack web applications (via lotusrb), but all the gems of this toolkit can be used as standalone components in existing Ruby applications.
It this case we will compose together the router and the actions to create a JSON API app that returns informations for books. »
Lotus development is going well. The experiment of open source a framework per month is sustainable. I have the time to cleanup the code, write a good documentation and deliver great solutions.
This month, I’m proud to announce Lotus::Controller.
It’s a small but powerful and fast framework. It works standalone or with Lotus::Router and it implements the Rack protocol.
Actions The core of Lotus::Controller are the actions. An action is an HTTP endpoint. »
The beauty of Lotus is the composition of its frameworks. Each of them is well designed to achieve one and only one goal. The main advantage of this architecture is that delevopers can easily use and reuse those frameworks in countless ways.
Lotus::Router accepts anonymous functions as endpoints. This feature can be used to build Sinatra with it.
Initial setup We need to setup a Gemfile with:
source 'https://rubygems.org' gem 'lotus-router' As second step, we create an Hello World application with Lotus::Router (run with rackup application. »
For me, the first step in the long path of building a web framework was an HTTP router. By understanding requests coming from an user, it pays back with an immediate gratification: start it, open a browser and see a result.
My hope was to embark on a short journey, and reuse as much as possible existing libraries. But I soon discovered that the biggest problem of Ruby web frameworks is reusability of components. »