Getting Started

Installation

Ratalada has no runtime dependencies of its own — install it alongside whichever server you want to run on:

# Gemfile
gem "ratalada"
gem "puma"     # or "falcon"
bundle install

Or without bundler:

gem install ratalada puma

Want the Sinatra or Grape DSL instead of the built-in router? Add its adapter gem — gem "ratalada-sinatra" or gem "ratalada-grape" — and require "ratalada/sinatra" / require "ratalada/grape". The Frontends guide explains why the gem name and the require path differ.

Your first server

# server.rb
require "ratalada/puma"

Server.run do |request|
  case request
  in ["GET", "/"] then "hello\n"
  end
end
ruby server.rb
# ratalada: puma listening on http://127.0.0.1:9292
curl http://localhost:9292/
# hello

Requiring ratalada/puma did two things: picked puma as the backend and defined the top-level Server constant. The block is your router — it receives every request and returns a handler for it. Anything the block doesn’t match is a 404, including a fall-through case ... in.

Where next


This site uses Just the Docs, a documentation theme for Jekyll.