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