handle db page not found improved
This commit is contained in:
1 parent
cbc00bee03
commit
85968e0609
2 files changed
+11
-5
No files matched your search
+4
-4
@@ -2,15 +2,15 @@ const {renderPage} = require('../render/page')
|
||||
const {get} = require('koa-route')
|
||||
const getPathWithNoTrailingSlash = require('../lib/url').getPathWithNoTrailingSlash
|
||||
|
||||
module.exports = function () {
|
||||
module.exports = function (handleNotFound) {
|
||||
return get('*', async ctx => {
|
||||
const path = getPathWithNoTrailingSlash(ctx.path)
|
||||
const body = await renderPage(path)
|
||||
if (body) {
|
||||
ctx.type = 'text/html'
|
||||
ctx.body = body
|
||||
} else {
|
||||
ctx.status = 404
|
||||
}
|
||||
} else {
|
||||
await handleNotFound(ctx)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user