Skip to content

atduskgreg/freddy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 15 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.

NB.: This repo comes with some basic scripts for running Freddy under Thin via Rack and for monitoring it with God. If you want to use them, you’ll need to edit some of the values to point at your copies of files. It should be pretty self-explanatory if you’re familiar with Thin and God (if not, see the links below).

JSONP:

en.wikipedia.org/wiki/JSON#JSONP

remysharp.com/2007/10/08/what-is-jsonp/

ajaxian.com/archives/jsonp-json-with-padding

Sinatra:

sinatra.github.com

Thin:

code.macournoyer.com/thin/

God:

github.com/mojombo/god/tree/master

About

A JSON-P server in Sinatra

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Ruby 100.0%