Sinatra::Jsonp

JSONP output helper for Sinatra. Automatically detects callback params and returns proper JSONP output.
If callback params where not detected it returns plain JSON.
Works with jQueryjQuery.getJSON out of the box.

Installation

Gem install

gem install sinatra-jsonp

Gemfile

gem'sinatra-jsonp'

Usage

Classic:

require"sinatra"require"sinatra/jsonp"get'/hello'dodata=["hello","hi","hallo"]JSONPdata# JSONP is an alias for jsonp methodend# define your own callback as second string paramget'/hi'dodata=["hello","hi","hallo"]jsonpdata,'functionA'end# same with symbol paramget'/hallo'dodata=["hello","hi","hallo"]jsonpdata,:functionBend