thrift/lib/nodejs/examples/httpServer.js
ra 779b9ac2ef THRIFT-2493:Node.js lib needs HTTP client
Client: node
Patch: Randy Abernethy

Clean up of many jshint warnings/errors, jsdoc for HttpConnect,
added support for https and Python to HttpConnect, added tests
for HttpConnect with https and promises.
2014-04-23 20:04:23 -07:00

32 lines
1.1 KiB
JavaScript

var thrift = require('thrift');
var helloSvc = require('./gen-nodejs/HelloSvc');
//ServiceHandler: Implement the hello service
var helloHandler = {
hello_func: function (result) {
console.log("Received Hello call");
result(null, "Hello from Node.js");
}
};
//ServiceOptions: The I/O stack for the service
var helloSvcOpt = {
handler: helloHandler,
processor: helloSvc,
protocol: thrift.TJSONProtocol,
transport: thrift.TBufferedTransport
};
//ServerOptions: Define server features
var serverOpt = {
services: {
"/hello": helloSvcOpt
}
}
//Create and start the web server
var port = 9090;
thrift.createWebServer(serverOpt).listen(port);
console.log("Http/Thrift Server running on port: " + port);