UNPKG

@opra/client

Version:
19 lines (18 loc) 729 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpInterceptorHandler = void 0; class HttpInterceptorHandler { constructor(interceptors, finalHandler) { this.chain = interceptors.reduceRight((chainTailFn, interceptor) => (initialRequest, handler) => interceptor.intercept(initialRequest, { handle: downstreamRequest => chainTailFn(downstreamRequest, handler), }), chainEnd); this.finalHandler = finalHandler; } handle(initialRequest) { return this.chain(initialRequest, req => this.finalHandler.handle(req)); } } exports.HttpInterceptorHandler = HttpInterceptorHandler; function chainEnd(req, handler) { return handler(req); }