A tiny JSONP proxy server written in Go
jsonpea
is an alternative to anyorigin.com or whateverorigin.org for local development. It's a little single-binary proxy server to work around same-origin issues while developing websites. It fetches the content from a given url
and calls the callback
function with the result.
go get github.com/greghaskins/jsonpea
Start up jsonpea
:
$ $GOPATH/bin/jsonpea
Listening on :7070 ...
Then hit http://localhost:7070
in another terminal or browser:
GET /get?url=http://httpbin.org/get&callback=doSomething HTTP/1.1
Host: localhost:7070
HTTP/1.1 200 OK
doSomething({
"args": {},
"headers": {
"Accept-Encoding": "gzip",
"Host": "httpbin.org",
"User-Agent": "Go 1.1 package http"
},
"origin": "...",
"url": "http://httpbin.org/get"
}
);
url
(required): The remote URL to load.callback
(optional): A named JavaScript function to be called with the payload passed as a parameter. If no callback is specified, the raw data is returned as-is.