x-ng2-http-interceptor
Version:
Adds interception capability around angular http api
91 lines • 4.35 kB
JavaScript
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
import { InterceptorRequestInternal } from './interceptor-request-internal';
import { Response } from '@angular/http';
import { InterceptorResponseWrapper } from './interceptor-response-wrapper';
import { InterceptorResponseWrapperBuilder } from './interceptor-response-wrapper-builder';
import { InterceptorUtils } from './interceptor-utils';
/**
* !!INTERNAL USE ONLY!!
* Utility builder for creating a new instance of InterceptorResponseWrapper with additional ability to set internal properties aswell
* Use InterceptorResponseWrapperBuilderInternal.new() to instantiate the builder
*/
export var InterceptorResponseWrapperBuilderInternal = (function (_super) {
__extends(InterceptorResponseWrapperBuilderInternal, _super);
/**
* Use InterceptorResponseWrapperBuilderInternal.new() to instantiate the builder
*/
function InterceptorResponseWrapperBuilderInternal() {
_super.call(this);
}
InterceptorResponseWrapperBuilderInternal.newInternal = function (interceptorStep, from) {
var builder = new InterceptorResponseWrapperBuilderInternal();
if (from instanceof Response) {
builder._response = from;
}
else if (from instanceof InterceptorResponseWrapper) {
InterceptorUtils.assign(builder, from);
}
else {
var request = new InterceptorRequestInternal();
InterceptorUtils.assign(request, from);
InterceptorUtils.assign(builder, from);
if (request.getShortCircuitAtCurrentStep()) {
builder.shortCircuitTriggeredBy(interceptorStep - 1)
.forceRequestCompletion(request.getAlsoForceRequestCompletion());
}
}
return builder;
};
InterceptorResponseWrapperBuilderInternal.prototype.url = function (url) {
this._url = url;
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.options = function (options) {
this._options = options;
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.response = function (response) {
if (response) {
_super.prototype.response.call(this, response);
}
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.sharedData = function (sharedData) {
_super.prototype.sharedData.call(this, sharedData);
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.shortCircuitTriggeredBy = function (shortCircuitTriggeredBy) {
this._shortCircuitTriggeredBy = shortCircuitTriggeredBy;
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.forceReturnResponse = function (forceReturnResponse) {
_super.prototype.forceReturnResponse.call(this, forceReturnResponse);
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.forceRequestCompletion = function (forceRequestCompletion) {
_super.prototype.forceRequestCompletion.call(this, forceRequestCompletion);
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.responseGeneratedByShortCircuitHandler = function (responseGeneratedByShortCircuitHandler) {
this._responseGeneratedByShortCircuitHandler = responseGeneratedByShortCircuitHandler;
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.err = function (err) {
_super.prototype.err.call(this, err);
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.errEncounteredAt = function (errEncounteredAt) {
this._errEncounteredAt = errEncounteredAt;
return this;
};
InterceptorResponseWrapperBuilderInternal.prototype.errEncounteredInRequestCycle = function (errEncounteredInRequestCycle) {
this._errEncounteredInRequestCycle = errEncounteredInRequestCycle;
return this;
};
return InterceptorResponseWrapperBuilderInternal;
}(InterceptorResponseWrapperBuilder));
//# sourceMappingURL=interceptor-response-wrapper-builder-internal.js.map