-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* removed provideInterceptors() * polished httpInterceptorService and fixed bugs in interceptor pipeline * change properties in IRestQuery to any type * added ngModule to http module, and provided interceptors with forRoot() to be inline with angular * updated docs with ngmodule notation for http module * reword example to setup in http module * created http.module.ts for CovalentHttpModule * updated README.md
- Loading branch information
1 parent
13110bf
commit 91050c5
Showing
7 changed files
with
96 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { NgModule, ModuleWithProviders, Type, Injector } from '@angular/core'; | ||
import { HttpModule, Http } from '@angular/http'; | ||
|
||
import { HttpInterceptorService } from './http-interceptor.service'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
HttpModule, | ||
], | ||
providers: [ | ||
HttpInterceptorService, | ||
], | ||
}) | ||
export class CovalentHttpModule { | ||
static forRoot(requestInterceptors: Type<any>[] = []): ModuleWithProviders { | ||
let providers: any[] = []; | ||
requestInterceptors.forEach((interceptor: Type<any>) => { | ||
providers.push(interceptor); | ||
}); | ||
providers.push({ | ||
provide: HttpInterceptorService, | ||
useFactory: (http: Http, injector: Injector): HttpInterceptorService => { | ||
return new HttpInterceptorService(http, injector, requestInterceptors); | ||
}, | ||
deps: [Http, Injector], | ||
}); | ||
return { | ||
ngModule: CovalentHttpModule, | ||
providers: providers, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { RESTService, IRestTransform, IRestConfig, IRestQuery, IHttp } from './http-rest.service'; | ||
export { IHttpInterceptor, HttpInterceptorService, provideInterceptors } from './http-interceptor.service'; | ||
export { IHttpInterceptor, HttpInterceptorService } from './http-interceptor.service'; | ||
export { CovalentHttpModule } from './http.module'; |