angular - How to override Http class in RC6? -


i have customhttp class , use add headers get requests:

import { injectable } '@angular/core'; import { observable } 'rxjs/rx'; import { requestoptionsargs, requestoptions, connectionbackend, http, request, response, headers } "@angular/http";  @injectable() export class customhttp extends http {  headers: headers = new headers({ 'something': 'something' }); options1: requestoptions = new requestoptions({ headers: this.headers });  constructor(backend: connectionbackend,     defaultoptions: requestoptions) {     super(backend, defaultoptions); }  get(url: string, options?: requestoptionsargs) {     console.log('custom get...');     return super.get(url, this.options1).catch(err => {         console.log(err);         if (err.status === 404) {             console.log('404 error');             return observable.throw(err);         }     });     } } 

in rc5, added appmodule providers this:

provide (http, {             usefactory: (                 backend: xhrbackend,                 defaultoptions: requestoptions) =>                 new customhttp(backend, defaultoptions),             deps: [xhrbackend, requestoptions]         }) 

but, in rc6, provide @angular/core deprecated , i'm having problems adding customhttp class appmodule providers. have idea how this?

the syntax has change bit, besides should still work same:

    { provide: http,          usefactory: (             backend: xhrbackend,             defaultoptions: requestoptions) =>             new customhttp(backend, defaultoptions),         deps: [xhrbackend, requestoptions]     } 

Comments