37 lines
726 B
JavaScript
37 lines
726 B
JavaScript
const config = require('settings/config');
|
|
|
|
let urls = {};
|
|
|
|
class Url {
|
|
constructor(url, view, name, method="GET") {
|
|
this.url = url;
|
|
this.view = view;
|
|
this.name = name;
|
|
this.method = method;
|
|
}
|
|
}
|
|
|
|
function getUrl(name) {
|
|
return urls[name].url;
|
|
}
|
|
|
|
function getStatic(name) {
|
|
return config.STATIC_URL + name
|
|
}
|
|
|
|
module.exports = function(req, res, next) {
|
|
res.locals.getUrl = getUrl;
|
|
res.locals.getStatic = getStatic;
|
|
return next();
|
|
}
|
|
|
|
module.exports.getUrl = getUrl;
|
|
module.exports.getStatic = getStatic;
|
|
|
|
module.exports.url = function(url, viewName, urlName, method) {
|
|
let ret = new Url(url, viewName, urlName, method);
|
|
urls[urlName] = ret;
|
|
return ret;
|
|
}
|
|
|