eshttp icon indicating copy to clipboard operation
eshttp copied to clipboard

Expose interface for custom backends

Open facekapow opened this issue 9 years ago • 0 comments

This is another runtime http related issue.

I think that there should be a way to add custom backends, because I had to access to many "private" properties while writing the http module for runtime. Maybe a class that provides default, overridable implementations of the methods? Something like:

const custom = new eshttp.HttpBackend({
  server: (serverInterface) => {
    return new SomeServer((socket) => {
      socket.on('data', (data) => serverInterface.ondata(data));
      socket.on('end', () => serverInterface.onend());
      socket.on('close', () => serverInterface.onclose());
      socket.on('error', (err) => serverInterface.onerror(err);
    });
  },
  client: (clientInterface) => {
    // ...
  }
});
custom.close = (socket) => socket.someOtherNameForClose();
// everything else is left as default

Anyway, it's just a proposal.

facekapow avatar May 01 '16 19:05 facekapow