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 { inject } from '@angular/core'; |
||||
import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; |
import { HttpHandlerFn, HttpInterceptorFn, HttpRequest } from '@angular/common/http'; |
||||
import { TimezoneService } from '../services'; |
import { TimezoneService } from '../services'; |
||||
import { Observable } from 'rxjs'; |
|
||||
|
|
||||
@Injectable({ |
export const timezoneInterceptor: HttpInterceptorFn = ( |
||||
providedIn: 'root', |
req: HttpRequest<any>, |
||||
}) |
next: HttpHandlerFn, |
||||
export class TimezoneInterceptor implements HttpInterceptor { |
) => { |
||||
protected readonly timezoneService = inject(TimezoneService); |
const timezoneService = inject(TimezoneService); |
||||
|
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { |
if (!timezoneService.isUtcClockEnabled) { |
||||
if (!this.timezoneService.isUtcClockEnabled) { |
return next(req); |
||||
return next.handle(req); |
|
||||
} |
|
||||
const timezone = this.timezoneService.timezone; |
|
||||
if (timezone) { |
|
||||
req = req.clone({ |
|
||||
setHeaders: { |
|
||||
__timezone: timezone, |
|
||||
}, |
|
||||
}); |
|
||||
} |
|
||||
return next.handle(req); |
|
||||
} |
} |
||||
} |
const timezone = timezoneService.timezone; |
||||
|
if (timezone) { |
||||
|
req = req.clone({ |
||||
|
setHeaders: { |
||||
|
__timezone: timezone, |
||||
|
}, |
||||
|
}); |
||||
|
} |
||||
|
return next(req); |
||||
|
}; |
||||
|
|||||
Loading…
Reference in new issue