node-web-mvc
Version:
node spring mvc
47 lines (46 loc) • 1.61 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class DefaultResourceResolverChain {
get invokeable() {
return this.resolver != null && this.nextChain != null;
}
constructor(resolvers, chain) {
if (arguments.length === 2) {
this.resolver = resolvers;
this.nextChain = chain;
}
else {
let chain = new DefaultResourceResolverChain(null, null);
resolvers = (resolvers || []);
resolvers.forEach((resolver) => {
chain = new DefaultResourceResolverChain(resolver, chain);
});
this.resolver = chain.resolver;
this.nextChain = chain.nextChain;
}
}
/**
* 根据当前请求以及解析配置来解析资源
* @param request 当前请求对象
* @param requestPath 当前请求路径
* @param locations 搜索范围位置
*/
async resolveResource(request, requestPath, locations) {
if (!this.invokeable) {
return null;
}
return await this.resolver.resolveResource(request, requestPath, locations, this.nextChain);
}
/**
* 根据当前请求以及解析配置来解析资源路径
* @param requestPath 当前请求路径
* @param locations 搜索范围位置
*/
async resolveUrlPath(resourcePath, locations) {
if (!this.invokeable) {
return null;
}
return await this.resolver.resolveUrlPath(resourcePath, locations, this.nextChain);
}
}
exports.default = DefaultResourceResolverChain;