Sinatra 1.3 is out!

Sinatra 1.3.0 is out with two big news items. The Chairman is now traveling with his own band. Sinatra Contrib, the community-sourced collection of extensions, is now versioned with Sinatra itself, ensuring compatibility. Sinatra Contrib provides some niceties on top of Sinatra for common tasks like config files, content_for, respond_with and other things you might miss from Rails.

Perhaps the bigger news is that Sinatra gigs can be streamed. No matter if you run evented servers like Thin, Rainbows! or Ebb or sequential servers like Unicorn, Passenger, or Mongrel, you have a single API:

get '/' do
 stream do |out|
   out << "It's gonna be legen -n"
   sleep 0.5
   out << " (wait for it) n"
   sleep 1
   out << "- dary!n"

Of course, you’ll need an evented server to keep connections open to things like:

set :server, :thin
connections = []

get '/' do
 # keep stream open
 stream(:keep_open) { |out| connections << out }

post '/' do
 # write to all open streams
 connections.each { |out| out << params[:message] << "n" }
 "message sent"

Smaller but just as cool changes include:

  • request.accept? for Accept headers
  • informal?, success?, redirect? and client_error? based on HTTP status code.
  • Support for If-Unmodified-Since header

Check out the official announcement or the changelog for a complete list of updates. Congrats to Konstantin Haase and the other contributors who made this happen.

News Films

Our little film studio focuses on telling developer-centric stories that need to be seen.

Beyond Code: Season 3 / GopherCon 2015

0:00 / 0:00