blob: acae1369a2f42bd413b89bb352d043aece466947 [file] [log] [blame]
ra779b9ac2014-04-23 20:04:23 -07001var thrift = require('thrift');
2var helloSvc = require('./gen-nodejs/HelloSvc');
3
4//ServiceHandler: Implement the hello service
5var helloHandler = {
6 hello_func: function (result) {
7 console.log("Received Hello call");
8 result(null, "Hello from Node.js");
9 }
10};
11
12//ServiceOptions: The I/O stack for the service
13var helloSvcOpt = {
14 handler: helloHandler,
15 processor: helloSvc,
16 protocol: thrift.TJSONProtocol,
17 transport: thrift.TBufferedTransport
18};
19
20//ServerOptions: Define server features
21var serverOpt = {
22 services: {
23 "/hello": helloSvcOpt
24 }
25}
26
27//Create and start the web server
28var port = 9090;
29thrift.createWebServer(serverOpt).listen(port);
30console.log("Http/Thrift Server running on port: " + port);
31