-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OZ-0003] fix for http/1 fallback and access logs
Add workaround for http/1 fallback. Reference: molnarg/node-http2#220 Add logging support
- Loading branch information
Showing
9 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,43 @@ | ||
var express = require('express'); | ||
var fs = require('fs'); | ||
var http = require('http'); | ||
var http2 = require('http2'); | ||
var morgan = require('morgan'); | ||
var path = require('path'); | ||
|
||
// Create Express Application | ||
var app = express(); | ||
|
||
express.request.__proto__ = http2.IncomingMessage.prototype; | ||
express.response.__proto__ = http2.ServerResponse.prototype; | ||
// Make HTTP2 work with Express (this must be before any other middleware) | ||
require('express-http2-workaround')({ express: express, http2: http2, app: app }); | ||
|
||
// create a write stream (in append mode) | ||
var logDirectory = './logs'; | ||
if (!fs.existsSync(logDirectory)){ | ||
fs.mkdirSync(logDirectory); | ||
} | ||
var accessLogStream = fs.createWriteStream(path.join(logDirectory, 'access.log'), {flags: 'a'}) | ||
|
||
var options = { | ||
key: fs.readFileSync('./node_modules/http2/example/localhost.key'), | ||
cert: fs.readFileSync('./node_modules/http2/example/localhost.crt') | ||
}; | ||
|
||
app.use(express.static('public')); | ||
http2 | ||
.createServer(options, app) | ||
.listen(443, function() { | ||
console.log("Express HTTP 2 server up and running."); | ||
}); | ||
|
||
app.get('/', function (req, res) { | ||
//res.send('Hello World'); | ||
res.redirect('/main.html'); | ||
}); | ||
http | ||
.Server(app) | ||
.listen(80, function() { | ||
console.log("Express HTTP 1 server up and running."); | ||
}); | ||
|
||
http2.createServer(options, app).listen(3001); | ||
app | ||
.use(morgan('combined', {stream: accessLogStream})) | ||
.use(express.static('public')) | ||
.get('/', function (req, res) { | ||
res.redirect('/main.html'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" type="text/css" href="css/theme.css"> | ||
<script type="text/javascript" src="js/Application.js"></script> | ||
<script type="text/javascript" src="js/DevSession.js"></script> | ||
</head> | ||
<body> | ||
<div class="vox-header"> List of Dev Sessions </div> | ||
<a class="option home" href="main.html">Home</a> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Application { | ||
constructor() {} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Configuration { | ||
constructor () {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class DevSession { | ||
constructor () {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
<html> | ||
<head> | ||
<link rel="stylesheet" type="text/css" href="css/theme.css"> | ||
<script type="text/javascript" src="js/Application.js"></script> | ||
<script type="text/javascript" src="js/Configuration.js"></script> | ||
</head> | ||
<body> | ||
<div class="vox-header"> Hello World. </div> | ||
<img src="images/singapore.jpeg" alt="SG" width="400" height="300"/> | ||
<a class="option dev-session" href="devSessionList.html">List of Topics</a> | ||
</body> | ||
</html> |