source files -> src/ folder
This commit is contained in:
1 parent
f006207112
commit
d25f4439fa
144 files changed
No files matched your search
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Created by tmshv on 01/03/15.
|
||||
*/
|
||||
|
||||
var path = require("path");
|
||||
var fs = require("mz/fs");
|
||||
var config = require("../config");
|
||||
|
||||
function accepts(routes, def) {
|
||||
return function *() {
|
||||
var req = this.request;
|
||||
var types = Object.keys(routes)
|
||||
.filter(function (type) {
|
||||
return req.accepts(type);
|
||||
});
|
||||
|
||||
if (types.length) {
|
||||
var type = types[0];
|
||||
yield routes[type].apply(this, arguments);
|
||||
} else if (def) {
|
||||
yield def;
|
||||
} else {
|
||||
this.status = 406;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function index(filename) {
|
||||
if (!filename) filename = config['defaultIndex'];
|
||||
|
||||
return function *() {
|
||||
this.type = "text/html";
|
||||
this.body = fs.createReadStream(filename);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
index: index,
|
||||
accepts: accepts
|
||||
};
|
||||
Reference in new issue
Block a user