A JSON-P server in Sinatra
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Freddy is a JSON Slasher!

Freddy is a standalone JSONP proxy written in Sinatra. Running Freddy lets you integrate JSON APIs that do not provide their own JSONP facilities in pages running on your own domain. For more information on JSONP or Sinatra follow the lnks at the bottom of this README.

Once you have deployed Freddy on your own server, access it like this:

freddy.mydomain.com?url=<uri-encoded json-returning url>&callback=<name of my callback function>

The response will look like this:

myCallback({'foo' : 'bar'})

Where myCallback is the value you provided for the 'callback' param and {'foo' : 'bar'} is the json returned by GETting the url you provided to the 'url' param.

If you do not provide both of the paramters or if the url given cannot be accessed, Freddy will return an error response in the following format:

myCallback({'error' : '<description of error>'})

Note: Freddy just straight up GETs the url and spits back the result. So, if the result is an HD rip of Berlin Alexanderplatz, then your server will (un-)happily start pulling that down. Freddy implements a timeout on getting the JSON of 3 seconds. If requesting your JSON takes longer than that, Freddy will return an error message in the format described above.

There is no security. If you run this, anyone who knows about your Freddy URL will be able to access it for their arbitrary use. Deploy with caution.