const exp = require("constants"); class ServerModel { constructor() { this.gets = {}; this.posts = {}; } get(url, callback) { this.gets[url] = callback; } post(url, callback) { this.posts[url] = callback; } trigger(method, url, req, res, query, data) { if(method == 'GET') { if(this.gets.hasOwnProperty(url)) { return this.gets[url](req, res, query); } }else if(method == 'POST') { if(this.posts.hasOwnProperty(url)) { return this.posts[url](req, res, query, data); } } return "无效的请求"; } } module.exports = { ServerModel }