Initial commit: Aeroflot Flights Web Angular 12 application

This commit is contained in:
2026-04-03 10:10:52 +03:00
commit 2342f2e66e
1311 changed files with 128350 additions and 0 deletions
@@ -0,0 +1,32 @@
import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { takeUntil, tap } from 'rxjs/operators';
import { HttpCancelService } from '../services/http-cancel.service';
@Injectable()
export class AppInterceptor implements HttpInterceptor {
constructor(private httpCancelService: HttpCancelService, private router: Router) {}
intercept<T>(req: HttpRequest<T>, next: HttpHandler): Observable<HttpEvent<T>> {
return next.handle(req).pipe(
takeUntil(this.httpCancelService.onCancelPendingRequests()),
tap({
next: () => {},
error: (err) => {
if (err instanceof HttpErrorResponse) {
switch (err.status) {
case 404:
this.router.navigateByUrl('/error/404');
break;
case 500:
this.router.navigateByUrl('/error');
break;
}
}
},
}),
);
}
}