|
|
@ -1,6 +1,13 @@ |
|
|
import { HttpHandler, HttpHeaders, HttpInterceptor, HttpRequest } from '@angular/common/http'; |
|
|
import { |
|
|
|
|
|
HttpHandler, |
|
|
|
|
|
HttpHeaders, |
|
|
|
|
|
HttpInterceptor, |
|
|
|
|
|
HttpRequest, |
|
|
|
|
|
HttpEvent, |
|
|
|
|
|
} from '@angular/common/http'; |
|
|
import { Injectable, inject } from '@angular/core'; |
|
|
import { Injectable, inject } from '@angular/core'; |
|
|
import { finalize } from 'rxjs/operators'; |
|
|
import { finalize } from 'rxjs/operators'; |
|
|
|
|
|
import { Observable } from 'rxjs'; |
|
|
import { HttpWaitService } from '../services'; |
|
|
import { HttpWaitService } from '../services'; |
|
|
|
|
|
|
|
|
@Injectable({ |
|
|
@Injectable({ |
|
|
@ -9,12 +16,11 @@ import { HttpWaitService } from '../services'; |
|
|
export class ApiInterceptor implements IApiInterceptor { |
|
|
export class ApiInterceptor implements IApiInterceptor { |
|
|
private httpWaitService = inject(HttpWaitService); |
|
|
private httpWaitService = inject(HttpWaitService); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getAdditionalHeaders(existingHeaders?: HttpHeaders) { |
|
|
getAdditionalHeaders(existingHeaders?: HttpHeaders) { |
|
|
return existingHeaders || new HttpHeaders(); |
|
|
return existingHeaders || new HttpHeaders(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
intercept(request: HttpRequest<any>, next: HttpHandler) { |
|
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { |
|
|
this.httpWaitService.addRequest(request); |
|
|
this.httpWaitService.addRequest(request); |
|
|
return next.handle(request).pipe(finalize(() => this.httpWaitService.deleteRequest(request))); |
|
|
return next.handle(request).pipe(finalize(() => this.httpWaitService.deleteRequest(request))); |
|
|
} |
|
|
} |
|
|
|