The API is described here:
https://github.com/Sage/streamlinejs/blob/master/lib/globals.md but it probably need a bit more explanation.
As the doc says, the streams module (or ez-streams) sets up an empty context at the beginning of every request. So you can just use this context:
var globals = require('streamline/lib/globals');
var ez = require('ez-streams');
ez.streams.devices.http.server(function(request, response, _) {
globals.context.request = request;
globals.context.response = response;
setTimeout(_, 0); // yield to the event loop
f1(_);
}).listen(_, port);
function f1(_) {
// retrieve from globals.request
var request = globals.context.request;
var response = globals.context.response;
}
Warning: the following will *not* work:
// top of the file
var context = require('streamline/lib/globals').context;
You can put whatever you want in the context. If all your code executes in the context of an HTTP request you can put the request/response pair. If your code needs to be more versatile (also work from command line, TCP server, etc), then you should put lower level objects like locale name, login id, security context).
Bruno