// alex
--I apologize for starting a new topic. It is because the subject of my previous post does not carry any meaning to my question.
I am trying to add a new URL path (Node.js home page has given an example to do it.) to a piece of complex existing code (shown below). The existing code already has server configuration code but the code looks very different from the "Building a Node.js Web Server" example that is showing in the Node.js home page.
The new URL path is "/lens/v1/ping" that is sent from the browser window.
If that is the URL path received, I am supposed to send a response Status 200 back to the browser.
I am having difficulties to fit this new URL path and its associated code to the existing code (show below) and I am seeking help. Thank you very much.
/** * Entry point for the RESTFul Service. */ var express = require('express') var config = require('config'); var _ = require('underscore'); var bodyParser = require("vcommons").bodyParser; // Export config, so that it can be used anywhere module.exports.config = config; var Log = require('vcommons').log; var logger = Log.getLogger('SUBSCRIBE', config.log); var http = require("http"); var https = require("https"); var fs = require("fs"); var cluster = require("cluster"); var numCPUs = require('os').cpus().length;if (cluster.isMaster) { // Fork workers. for (var i = 0; i < numCPUs; i++) { cluster.fork(); } cluster.on('online', function (worker) { logger.info('A worker with #' + worker.id); }); cluster.on('listening', function (worker, address) { logger.info('A worker is now connected to ' + address.address + ':' + address.port); }); cluster.on('exit', function (worker, code, signal) { logger.info('worker ' + worker.process.pid + ' died'); }); } else { logger.info("Starting Subscription Application"); createApp(); } // Create Express App function createApp() { var app = express(); app.configure(function () { // enable web server logging; pipe those log messages through winston var winstonStream = { write : function (message, encoding) { logger.trace(message); } }; // Log app.use(bodyParser({})); app.use(app.router); if (config.debug) { app.use(express.errorHandler({ showStack : true, dumpExceptions : true })); } }); // Include Router var router = require('../lib/router')(); // Subscribe to changes by certain domain for a person app.post('/lens/v1/:assigningAuthority/:identifier/*', router.submitRequest); // Listen if (!_.isUndefined(config.server) || !_.isUndefined(config.secureServer)) { if (!_.isUndefined(config.server)) { http.createServer(app).listen(config.server.port, config.server.host, function () { logger.info("Subscribe server listening at http://" + config.server.host + ":" + config.server.port); }); } if (!_.isUndefined(config.secureServer)) { https.createServer(fixOptions(config.secureServer.options), app).listen (config.secureServer.port, config.secureServer.host, function () { logger.info("Subscribe server listening at https://" + config.secureServer.host + ":" + config.secureServer.port); }); } } else { logger.error("Configuration must contain a server or secureServer."); process.exit(); } } function fixOptions(configOptions) { var options = {}; if (!_.isUndefined(configOptions.key) && _.isString(configOptions.key)) { options.key = fs.readFileSync(configOptions.key); } if (!_.isUndefined(configOptions.cert) && _.isString(configOptions.cert)) { options.cert = fs.readFileSync(configOptions.cert); } if (!_.isUndefined(configOptions.pfx) && _.isString(configOptions.pfx)) { options.pfx = fs.readFileSync(configOptions.pfx); } return options; } // Default exception handler process.on('uncaughtException', function (err) { logger.error('Caught exception: ' + err); process.exit() }); // Ctrl-C Shutdown process.on('SIGINT', function () { logger.info("Shutting down from SIGINT (Crtl-C)") process.exit() }) // Default exception handler process.on('exit', function (err) { logger.info('Exiting.. Error:', err); });--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
