Handle push state entirely
This commit is contained in:
parent
4f00d3c71a
commit
6597dba36d
4 changed files with 56 additions and 9 deletions
|
@ -41,4 +41,6 @@ DocumentHandler.prototype.handlePost = function(request, response) {
|
|||
});
|
||||
};
|
||||
|
||||
// TODO block modifying
|
||||
|
||||
module.exports = DocumentHandler;
|
||||
|
|
|
@ -25,6 +25,7 @@ StaticHandler.contentTypeFor = function(ext) {
|
|||
// Handle a request, and serve back the asset if it exists
|
||||
StaticHandler.prototype.handle = function(incPath, response) {
|
||||
var filePath = this.basePath + (incPath == '/' ? this.defaultPath : incPath);
|
||||
var _this = this;
|
||||
path.exists(filePath, function(exists) {
|
||||
if (exists) {
|
||||
fs.readFile(filePath, function(error, content) {
|
||||
|
@ -41,9 +42,11 @@ StaticHandler.prototype.handle = function(incPath, response) {
|
|||
});
|
||||
}
|
||||
else {
|
||||
winston.warn('file not found', { path: filePath });
|
||||
response.writeHead(404, { 'content-type': 'application/json' });
|
||||
response.end(JSON.stringify({ message: 'file not found' }));
|
||||
// TODO 404 if not match regex
|
||||
//winston.warn('file not found', { path: filePath });
|
||||
//response.writeHead(404, { 'content-type': 'application/json' });
|
||||
//response.end(JSON.stringify({ message: 'file not found' }));
|
||||
_this.handle('/', response);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue