import {Inject, Injectable, Optional} from '@angular/core';
import {HttpBackend, HttpClient, HttpInterceptor} from '@angular/common/http';

import {CustomHttpHandler} from 'm2-core';
import {CD_HTTP_INTERCEPTORS} from './cd-interceptor-providers';


@Injectable({
    providedIn: 'root'
})
export class CdHttpClient extends HttpClient {

    constructor(
        handler: HttpBackend,
        @Optional() @Inject(CD_HTTP_INTERCEPTORS) interceptors: HttpInterceptor[]
    ) {
        super(new CustomHttpHandler(handler, interceptors));
    }

}
