You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Hydro/hydro/handler/wiki.js

25 lines
686 B
JavaScript

4 years ago
const { Route, Handler } = require('../service/server');
const { NotFoundError } = require('../error');
5 years ago
5 years ago
class WikiHandler extends Handler {
async get({ name }) {
4 years ago
if (!global.Hydro.wiki[name]) throw new NotFoundError(name);
const contents = global.Hydro.wiki[name];
5 years ago
const path = [
['Hydro', '/'],
['wiki', '/wiki'],
5 years ago
[`wiki_${name}`, null],
5 years ago
];
5 years ago
this.response.body = {
path, contents, page_name: `wiki_${name}`,
};
this.response.template = 'wiki.html';
5 years ago
}
}
async function apply() {
4 years ago
Route('/wiki/:name', WikiHandler);
5 years ago
}
4 years ago
global.Hydro.handler.wiki = module.exports = apply;