mirror of https://github.com/abpframework/abp.git
2 changed files with 21 additions and 30 deletions
@ -1,26 +1,23 @@ |
|||
import { inject, Injectable } from '@angular/core'; |
|||
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; |
|||
import { inject } from '@angular/core'; |
|||
import { HttpHandlerFn, HttpInterceptorFn, HttpRequest } from '@angular/common/http'; |
|||
import { TimezoneService } from '../services'; |
|||
import { Observable } from 'rxjs'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root', |
|||
}) |
|||
export class TimezoneInterceptor implements HttpInterceptor { |
|||
protected readonly timezoneService = inject(TimezoneService); |
|||
export const timezoneInterceptor: HttpInterceptorFn = ( |
|||
req: HttpRequest<any>, |
|||
next: HttpHandlerFn, |
|||
) => { |
|||
const timezoneService = inject(TimezoneService); |
|||
|
|||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { |
|||
if (!this.timezoneService.isUtcClockEnabled) { |
|||
return next.handle(req); |
|||
} |
|||
const timezone = this.timezoneService.timezone; |
|||
if (timezone) { |
|||
req = req.clone({ |
|||
setHeaders: { |
|||
__timezone: timezone, |
|||
}, |
|||
}); |
|||
} |
|||
return next.handle(req); |
|||
if (!timezoneService.isUtcClockEnabled) { |
|||
return next(req); |
|||
} |
|||
} |
|||
const timezone = timezoneService.timezone; |
|||
if (timezone) { |
|||
req = req.clone({ |
|||
setHeaders: { |
|||
__timezone: timezone, |
|||
}, |
|||
}); |
|||
} |
|||
return next(req); |
|||
}; |
|||
|
|||
Loading…
Reference in new issue