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_withand 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" end endOf 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 } end post '/' do # write to all open streams connections.each { |out| out << params[:message] << "\n" } "message sent" endSmaller but just as cool changes include:
request.accept?forAcceptheadersinformal?,success?,redirect?andclient_error?based on HTTP status code.- Support for
If-Unmodified-SinceheaderCheck 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.