Skip to content

Access to req, res objects  #135

@samuelbodin

Description

@samuelbodin

From the examples it's not entirely clear to me how I can access data that I pass to the bindEmitter() function. In the code below I use the createServer from the http module. Now my question is, how can I save the request and response objects to later access them from my foo function?

var createNamespace = require('continuation-local-storage').createNamespace;
var session  = createNamespace('some namespace');
var http = require('http');

function foo() {
    // How do I access res/req from here?
}

http.createServer(function (req, res) {
  session.bindEmitter(req);
  session.bindEmitter(res);

  // Call foo without passing in req and res.
  foo();
}).listen(8000);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions