404 ES6 refactoring, export signature change
This commit is contained in:
1 parent
7901aecdda
commit
f2185c5f8c
2 files changed
+14
-19
No files matched your search
+12
-17
@@ -1,31 +1,26 @@
|
|||||||
/**
|
import {index, accepts} from './';
|
||||||
* Created by tmshv on 01/03/15.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var route = require("koa-route");
|
export default function () {
|
||||||
var router = require("./");
|
return function *(next) {
|
||||||
|
|
||||||
module.exports = function (app) {
|
|
||||||
app.use(function *(next) {
|
|
||||||
yield next;
|
yield next;
|
||||||
|
|
||||||
if (404 != this.status) return;
|
if (404 != this.status) return;
|
||||||
|
|
||||||
this.status = 404;
|
this.status = 404;
|
||||||
yield router.accepts({
|
yield accepts({
|
||||||
"text/html": router.index(),
|
'text/html': index(),
|
||||||
|
|
||||||
"text/plain": function *() {
|
'text/plain': function *() {
|
||||||
this.type = "text/plain";
|
this.type = 'text/plain';
|
||||||
this.body = "Page not found";
|
this.body = 'Page not found';
|
||||||
},
|
},
|
||||||
|
|
||||||
"application/json": function *() {
|
'application/json': function *() {
|
||||||
this.type = "application/json";
|
this.type = 'application/json';
|
||||||
this.body = {
|
this.body = {
|
||||||
message: "Not Found"
|
message: 'Not Found'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
};
|
};
|
||||||
+2
-2
@@ -18,7 +18,7 @@ import news from './routes/news';
|
|||||||
import gallery from './routes/gallery';
|
import gallery from './routes/gallery';
|
||||||
import instagram from './instagram/router';
|
import instagram from './instagram/router';
|
||||||
import instagramIO from './instagram/io';
|
import instagramIO from './instagram/io';
|
||||||
import e404 from './routes/404';
|
import error404 from './routes/404';
|
||||||
import documents from './routes/documents';
|
import documents from './routes/documents';
|
||||||
import collective from './routes/collective';
|
import collective from './routes/collective';
|
||||||
|
|
||||||
@@ -52,6 +52,6 @@ news(app);
|
|||||||
gallery(app);
|
gallery(app);
|
||||||
instagram(app);
|
instagram(app);
|
||||||
instagramIO(app);
|
instagramIO(app);
|
||||||
e404(app);
|
|
||||||
documents(app);
|
documents(app);
|
||||||
collective(app);
|
collective(app);
|
||||||
|
app.use(error404());
|
||||||
Reference in new issue
Block a user