let info=util.handleMockInfo(req.param,req.query,req.body,req.headers,req.obj,req.protocol+"://"+req.headers.host+req.originalUrl); if(!param.outInfo || param.outInfo.type==0)
/** * Passing the request url to environment locals */ app.use(function (req, res, next) { res.locals.url = req.protocol + "://" + req.headers.host + req.url; res.locals.route = req.url; res.locals.path = req.protocol + "://" + req.headers.host; //res.setHeader('Cache-Control', 'public, max-age=600'); // Enable for caching session-flash next(); });
app.post('/rest/2.2/users/:user_id/mailings', function(req, res) { var mailingUrl = req.protocol + '://' + req.get('host') + '/rest/2.2/users/' + req.params.user_id + '/mailings/' + testMailingId; // {"name":"Mobile App mailing 2015-04-22 20:03", "productId":2, "source":"MOBILE", "addressFormat":"PERSON_FIRST"} if (!req.body || !req.body.name || !req.body.productId || !req.body.source || !req.body.addressFormat) { return res.status(400) .send('Bad Request, missing JSON POST parameters') .end(); } // all is fine, return a 201 Created. res.status(201) .location(mailingUrl) .end(); });
let index = (req: Request, res: Response) => { res.json({data:{ host:req.host, originalUrl:req.originalUrl, protocol : req.protocol, }}); }
app.get('/', (req, res) => { pageViews++ console.log(req.protocol, req.hostname, req.url) res.sendFile(__dirname + '/files/helloworld.html') })
app.use(function(req, res, next) { if (httpAllowedHosts.indexOf(req.hostname) >= 0) { return next(); } if (req.protocol !== 'https') { var url = 'https://' + req.hostname + req.url; res.redirect(301, url); } else { if (options.settings.strictTransportSecurity) { res.setHeader('Strict-Transport-Security', options.settings.strictTransportSecurity); } next(); } });
// A middleware for log app.use(function(req, res, next){ var fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl; console.log('Url: ' + fullUrl, 'debug'); console.log('Params: ' + JSON.stringify(req.params), 'debug'); console.log('Query: ' + JSON.stringify(req.query), 'debug'); next(); })
//Handle each request and ensure proper locals are set that are needed by app app.use(function(req, res, next) { res.locals._csrf = req.csrfToken(); if (req.query.searchtext) { res.locals.searchtext = req.query.searchtext; } res.locals.encodedUrl = encodeURIComponent(req.protocol + '://' + req.get('host') + req.originalUrl); next(); });
/** * And Our Default Route */ router.get('/', function (req, res) { // record the application base URL here db.set("baseURL", req.protocol + '://' + req.get('host')); console.log("setting the baseURL: " + db.get("baseURL")); res.render('tvml/index',{baseURL: db.get("baseURL")}); });
app.use(function(req, res, next){ if(req.protocol == "http"){ res.redirect("https://"+req.hostname+req.originalUrl); return; } res.locals.siteName = config.siteName; res.locals.cates = config.cates; res.locals.user = req.session.user; next(); });
app.use(function(req, res, next){ if(req.secure || (req.protocol === "https") || (req.get("x-forwarded-proto") === "https")){ next(); } else{ res.redirect("https://" + req.headers.host + req.url); } });
// redirect HTTP to HTTPS views.use(function (req, res, next) { if (!/https/.test(req.protocol)) { return res.redirect("https://" + req.headers.host + req.url) } else { return next() } })
/** * Passing the request url to environment locals */ app.use(function (req, res, next) { res.locals.uri = req.protocol + "://" + req.headers.host + req.url; res.locals.url = req.url; res.locals.route = req.url; res.locals.path = req.protocol + "://" + req.headers.host; //res.setHeader('Cache-Control', 'public, max-age=600'); // Enable for caching session-flash next(); });
// Passing the request url to environment locals app.use(function(req, res, next) { res.locals.url = req.protocol + '://' + req.headers.host + req.url; next(); });
// redirect HTTP to HTTPS views.use(function (req, res, next) { if (!/https/.test(req.protocol)) { return res.redirect("https://" + req.headers.host + req.url) } else { return next() } })