使用url()来构建url

This commit is contained in:
masnn committed 2020-06-12 13:37:19 +08:00
1 parent 0efac48bde
commit 86f67a0ec3
61 files changed
+262 -275

No files matched your search

+6 -6
View File
@@ -2,23 +2,23 @@ const { Route, Handler } = require('../service/server');
const { NotFoundError } = require('../error');
class WikiHandler extends Handler {
async get({ name }) {
if (!global.Hydro.wiki[name]) throw new NotFoundError(name);
const contents = global.Hydro.wiki[name];
async get({ name: page }) {
if (!global.Hydro.wiki[page]) throw new NotFoundError(page);
const contents = global.Hydro.wiki[page];
const path = [
['Hydro', '/'],
['wiki', '/wiki'],
[`wiki_${name}`, null],
[`wiki_${page}`, null],
];
this.response.body = {
path, contents, page_name: `wiki_${name}`,
path, contents, page_name: `wiki_${page}`,
};
this.response.template = 'wiki.html';
}
}
async function apply() {
Route('/wiki/:name', WikiHandler);
Route('wiki', '/wiki/:page', WikiHandler);
}
global.Hydro.handler.wiki = module.exports = apply;