The Skinny On...
Core
<< Back
The core of the reasonably smart platform is very simple. When
a request is made to your host, RSP looks for a file called
js/bootstrap.js, and executes it.
In return the RSP expects an Array object, that has the following structure:
- The first element of the Array is an Integer HTTP status code, 200 for Ok, 500 for Server Error, etc
- The second element of the Array is a string that forms the status line. "Ok", "Server Error", etc
- The third element of the Array is another array containing the
headers. For example:
['Content-Type', 'text/html']. The order of the headers is not important. - The final element of the Array should be the body of the response, either as a string, or as a FileSystem object
Other than that, you're free to do what you want. The devil of course, is in the details.
The contents of the request to your web host can be found in
the system.request object, that has the following
structure:
method- this is the HTTP method, or verb. GET, PUT, POST, DELETE, etcuri- this is the path of the request. If the request was forhttp://example.com/my/paththe uri would contain/my/path.query- this is an Object containing the query parameters of the request. Each of the parameters is a key, and each of the query values is, well, it's a value. One thing to look out for, or take advantage of, is if the same parameter is passed twice. In that case you'll get an Array instead of a String as the value.content- this is the content of the request body. You may want to parse it in a form-encoded fashion, or you may want to do something else entirelyheaders- these are the request headers stored as an Object. For various reasons they are all lower-cased. For example, the Content-Length header is stored ascontent-length.
A very simple example of a valid and working bootstrap.js could look like this:
[200, "Ok", ['Content-Type','text/plain'], "You requested " + system.request.uri];
