UNPKG

@anglr/rest

Version:

Angular module representing rest services

35 lines 1.68 kB
import { HttpContext } from '@angular/common/http'; import { PROGRESS_INDICATOR_GROUP_NAME } from '@anglr/common'; import { isBlank } from '@jscrpt/common'; /** * Middleware that is used for adding support for progress indicator group passing down to progress interceptor */ export class ProgressIndicatorGroupMiddleware { //######################### public static properties ######################### /** * String identification of middleware */ static { this.id = 'ProgressIndicatorGroupMiddleware'; } //######################### public methods - implementation of RestMiddleware ######################### /** * Runs code that is defined for this rest middleware, in this method you can modify request and response * @param this - Method is bound to RESTClient * @param id - Unique id that identifies request method * @param target - Prototype of class that are decorators applied to * @param methodName - Name of method that is being modified * @param descriptor - Descriptor of method that is being modified * @param args - Array of arguments passed to called method * @param request - Http request that you can modify * @param next - Used for calling next middleware with modified request */ run(_id, _target, _methodName, descriptor, _args, request, next) { if (isBlank(descriptor.groupName)) { return next(request); } request = request.clone({ context: new HttpContext().set(PROGRESS_INDICATOR_GROUP_NAME, descriptor.groupName) }); return next(request); } } //# sourceMappingURL=progressIndicatorGroup.middleware.js.map