cljsbin
cljsbin copied to clipboard
httpbin implemented in ClojureScript
cljsbin - HTTP Request & Response Service
cljsbin is a ClojureScript clone of httpbin that runs on Node.js. It provides an API to test common HTTP features and operations (request methods, headers, redirects, etc.).
cljsbin is implemented using the Macchiato web framework for ClojureScript.
Endpoints
/home page./ipReturns Origin IP./user-agentReturns user-agent./headersReturns header dict./getReturns GET data./postReturns POST data./putReturns PUT data./patchReturns PATCH data./deleteReturns DELETE data./forms/postHTML form that submits to /post/status/:statusReturns given HTTP Status code./response-headersReturns given response headers./cookies Returncookie data./cookies/set?name=valueSets one or more simple cookies./cookies/delete?nameDeletes one or more simple cookies./cacheReturns 200 unless an If-Modified-Since or If-None-Match header is provided, when it returns a 304./cache/:nSets a Cache-Control header for n seconds./delay/:nDelays responding for min(n, 10) seconds./redirect/:n302 relative redirects n times./absolute-redirect/:n302 absolyte redirects n times./redirect-to?url=foo302 Redirects to the given URL./basic-auth/:user/:passChallenges HTTPBasic Auth./hidden-basic-auth/:user/:pass404'd BasicAuth./digest-auth/:user/:passChallenges HTTP Digest Auth./links/:nReturns page containing n HTML links./encoding/utf8Returns page containing UTF-8 data./xmlReturns some XML./htmlRenders an HTML Page./robots.txtReturns some robots.txt rules./denyDenied by robots.txt file./imageReturns page containing an image based on sent Accept header./image/pngReturns page containing a PNG image./image/webpReturns page containing a WEBP image./image/svgReturns page containing a SVG image./image/jpegReturns page containing a JPEG image./compressReturns gzip or deflate enconded data, based on the Accept-encoding header.
Examples
GET /ip
{"origin": "24.127.96.129"}
GET /user-agent
{"user-agent": "curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3"}
GET /get
{
"args": {},
"headers": {
"Accept": "*/*",
"Connection": "close",
"Content-Length": "",
"Content-Type": "",
"Host": "cljsbin.org",
"User-Agent": "curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3"
},
"origin": "24.127.96.129",
"url": "http://cljsbin.org/get"
}
GET /status/418
HTTP/1.1 418 I'M A TEAPOT
Server: nginx/0.7.67
Date: Mon, 13 Jun 2011 04:25:38 GMT
Connection: close
x-more-info: http://tools.ietf.org/html/rfc2324
Content-Length: 135
Building and running
Prequisites
Node.js and leiningen need to be installed to run the application.
Running in development mode
run the following command in the terminal to install NPM modules and start Figwheel:
lein build
run node in another terminal:
npm start
Building the release version
lein package
Run the release version:
npm start
Build from the Dockerfile
From a folder containing the Dockerfile build the container:
docker build -t cljsbin .
And the run it:
docker run -p 3000:3000 cljsbin
Deploy using now
From a folder containing the Dockerfile build the container:
now
Currently live here.