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 @@
|
||||
/**
|
||||
* Created by tmshv on 01/03/15.
|
||||
*/
|
||||
import {index, accepts} from './';
|
||||
|
||||
var route = require("koa-route");
|
||||
var router = require("./");
|
||||
|
||||
module.exports = function (app) {
|
||||
app.use(function *(next) {
|
||||
export default function () {
|
||||
return function *(next) {
|
||||
yield next;
|
||||
|
||||
if (404 != this.status) return;
|
||||
|
||||
this.status = 404;
|
||||
yield router.accepts({
|
||||
"text/html": router.index(),
|
||||
yield accepts({
|
||||
'text/html': index(),
|
||||
|
||||
"text/plain": function *() {
|
||||
this.type = "text/plain";
|
||||
this.body = "Page not found";
|
||||
'text/plain': function *() {
|
||||
this.type = 'text/plain';
|
||||
this.body = 'Page not found';
|
||||
},
|
||||
|
||||
"application/json": function *() {
|
||||
this.type = "application/json";
|
||||
'application/json': function *() {
|
||||
this.type = 'application/json';
|
||||
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 instagram from './instagram/router';
|
||||
import instagramIO from './instagram/io';
|
||||
import e404 from './routes/404';
|
||||
import error404 from './routes/404';
|
||||
import documents from './routes/documents';
|
||||
import collective from './routes/collective';
|
||||
|
||||
@@ -52,6 +52,6 @@ news(app);
|
||||
gallery(app);
|
||||
instagram(app);
|
||||
instagramIO(app);
|
||||
e404(app);
|
||||
documents(app);
|
||||
collective(app);
|
||||
app.use(error404());
|
||||
Reference in new issue
Block a user