This repository has been archived on 2025-03-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
layc/src/Routing/BaseRouter.js
2024-03-20 03:43:27 +00:00

52 lines
1.2 KiB
JavaScript

import Logger from '../Utils/Logger';
export default class BaseRouter {
add(path, cb, options = {}) {
Logger.error('add method not implemented');
}
any(path, cb) {
this.all(path, cb);
}
all(path, cb) {
this.add(path, cb, { ...(arguments[2] || {}), method: 'all' });
return this;
}
get(path, cb) {
this.add(path, cb, { ...(arguments[2] || {}), method: 'get' });
return this;
}
post(path, cb) {
this.add(path, cb, { ...(arguments[2] || {}), method: 'post' });
return this;
}
put(path, cb) {
this.add(path, cb, { ...(arguments[2] || {}), method: 'put' });
return this;
}
patch(path, cb) {
this.add(path, cb, { ...(arguments[2] || {}), method: 'patch' });
return this;
}
delete(path, cb) {
this.add(path, cb, { ...(arguments[2] || {}), method: 'delete' });
return this;
}
head(path, cb) {
this.add(path, cb, { ...(arguments[2] || {}), method: 'head' });
return this;
}
options(path, cb) {
this.add(path, cb, { ...(arguments[2] || {}), method: 'options' });
return this;
}
}