Jens Geyer | b9d5522 | 2014-01-10 21:26:25 +0100 | [diff] [blame] | 1 | /*
|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one
|
| 3 | * or more contributor license agreements. See the NOTICE file
|
| 4 | * distributed with this work for additional information
|
| 5 | * regarding copyright ownership. The ASF licenses this file
|
| 6 | * to you under the Apache License, Version 2.0 (the
|
| 7 | * "License"); you may not use this file except in compliance
|
| 8 | * with the License. You may obtain a copy of the License at
|
| 9 | *
|
| 10 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 11 | *
|
| 12 | * Unless required by applicable law or agreed to in writing,
|
| 13 | * software distributed under the License is distributed on an
|
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
| 15 | * KIND, either express or implied. See the License for the
|
| 16 | * specific language governing permissions and limitations
|
| 17 | * under the License.
|
| 18 | */
|
| 19 |
|
| 20 | //This HTTP server is designed to server the test.html browser
|
| 21 | // based JavaScript test page (which must be in the current directory).
|
| 22 | // This server also supplies the Thrift based test service, which depends
|
| 23 | // on the standard ThriftTest.thrift IDL service (which must be compiled
|
| 24 | // for Node and browser based JavaScript in ./gen-nodejs and ./gen-js
|
| 25 | // respectively). The current directory must also include the browser
|
| 26 | // support libraries for test.html (jquery.js, qunit.js and qunit.css
|
| 27 | // in ./build/js/lib).
|
| 28 |
|
henrique | 2f51f32 | 2014-02-07 14:12:56 +0100 | [diff] [blame^] | 29 | var thrift = require('../../nodejs/lib/thrift');
|
| 30 | var TBufferedTransport = require('../../nodejs/lib/thrift/transport').TBufferedTransport;
|
| 31 | var TJSONProtocol = require('../../nodejs/lib/thrift/protocol').TJSONProtocol;
|
Jens Geyer | b9d5522 | 2014-01-10 21:26:25 +0100 | [diff] [blame] | 32 | var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
|
| 33 | var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
|
| 34 |
|
| 35 | var ThriftTestSvcOpt = {
|
| 36 | transport: TBufferedTransport,
|
| 37 | protocol: TJSONProtocol,
|
| 38 | cls: ThriftTestSvc,
|
| 39 | handler: ThriftTestHandler
|
| 40 | };
|
| 41 |
|
| 42 | var StaticHttpThriftServerOptions = {
|
| 43 | staticFilePath: ".",
|
| 44 | services: {
|
| 45 | "/service": ThriftTestSvcOpt
|
| 46 | }
|
henrique | 2f51f32 | 2014-02-07 14:12:56 +0100 | [diff] [blame^] | 47 | };
|
Jens Geyer | b9d5522 | 2014-01-10 21:26:25 +0100 | [diff] [blame] | 48 |
|
| 49 | var server = thrift.createStaticHttpThriftServer(StaticHttpThriftServerOptions);
|
| 50 | var port = 8088;
|
| 51 | server.listen(port);
|
henrique | 2f51f32 | 2014-02-07 14:12:56 +0100 | [diff] [blame^] | 52 | console.log("Serving files from: " + __dirname);
|
Jens Geyer | b9d5522 | 2014-01-10 21:26:25 +0100 | [diff] [blame] | 53 | console.log("Http/Thrift Server running on port: " + port);
|