API Reference

In the live editor where you implement your API, you are required to implement and return a javascript function.

This function will be passed a transaction object, where you may retrieve details about the request, and pass contents of the response. When you're done dealing with the request, you must call the ready() function of the transaction object, in order for a response to be returned to the client.

 * Function to handle requests and prepare responses
var process = function(transaction) {
	return transaction.setJSON({}).ready();
return process;

Generic information

The request object is available as transaction.req.

The base URL of the server, such as http://379.httpjs.net/.
Do not show this transaction in the output above. In example use this for favicons and OPTIONS requests, if they clutter your debugging info.

The request

The request object is available as transaction.req.

A indexed object containing the headers in the request.
The path of the request, including the query string if present
The path of the request, including the query string if present
The IP address of the requesting client.
The HTTP method of the request, such as GET, PUT or POST.
An object representing the query string as parameters.
The parsed body of the request. If no body was included in the request, this property will be an empty object. It is a parsed object, both if the real request body was encoded in JSON or as form-encoded.
To be supported later. Stay tuned.

Preparing the response

Most importantly remember to always call the transaction.ready() when completed.

transaction.setHeader(key, val)
Set HTTP response header
transaction.setBody(text, type)
Set HTTP response body as a string. Optionally provide the content type as a second parameter.
Set HTTP response by passing a JSON object. The Content-type, and JSON serialization will be handled automatically.
Set HTTP status code in the response..
Redirect to a new URL. Will return 302 with HTML content.
Returns 500 Internal error witha HTML output with the included message.
Returns 404 Not found.


We hope you find this tool useful. For comments contact Andreas Åkre Solberg or ask questions, request features or report issues.