2016-06-23 12:47:54 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
2015-07-28 16:10:25 -04:00
|
|
|
/**
|
|
|
|
* @module
|
|
|
|
* @description
|
|
|
|
* The http module provides services to perform http requests. To get started, see the {@link Http}
|
|
|
|
* class.
|
|
|
|
*/
|
2016-07-27 16:09:05 -04:00
|
|
|
import {NgModule} from '@angular/core';
|
2016-06-08 19:38:52 -04:00
|
|
|
|
2016-04-28 20:50:03 -04:00
|
|
|
import {BrowserJsonp} from './src/backends/browser_jsonp';
|
2016-06-08 19:38:52 -04:00
|
|
|
import {BrowserXhr} from './src/backends/browser_xhr';
|
2016-08-23 19:34:57 -04:00
|
|
|
import {JSONPBackend, JSONPBackend_} from './src/backends/jsonp_backend';
|
|
|
|
import {CookieXSRFStrategy, XHRBackend} from './src/backends/xhr_backend';
|
2016-04-28 20:50:03 -04:00
|
|
|
import {BaseRequestOptions, RequestOptions} from './src/base_request_options';
|
|
|
|
import {BaseResponseOptions, ResponseOptions} from './src/base_response_options';
|
2016-06-08 19:38:52 -04:00
|
|
|
import {Http, Jsonp} from './src/http';
|
2016-08-23 19:34:57 -04:00
|
|
|
import {XSRFStrategy} from './src/interfaces';
|
2015-07-28 16:10:25 -04:00
|
|
|
|
2016-06-28 14:31:35 -04:00
|
|
|
|
2016-07-27 16:09:05 -04:00
|
|
|
export function _createDefaultCookieXSRFStrategy() {
|
|
|
|
return new CookieXSRFStrategy();
|
|
|
|
}
|
2016-06-27 15:27:23 -04:00
|
|
|
|
2016-06-01 17:58:11 -04:00
|
|
|
export function httpFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions): Http {
|
2016-06-02 20:30:40 -04:00
|
|
|
return new Http(xhrBackend, requestOptions);
|
|
|
|
}
|
|
|
|
|
2016-08-12 14:30:12 -04:00
|
|
|
export function jsonpFactory(jsonpBackend: JSONPBackend, requestOptions: RequestOptions): Jsonp {
|
2016-06-02 20:30:40 -04:00
|
|
|
return new Jsonp(jsonpBackend, requestOptions);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-27 16:09:05 -04:00
|
|
|
/**
|
|
|
|
* The module that includes http's providers
|
|
|
|
*
|
|
|
|
* @experimental
|
|
|
|
*/
|
2016-08-18 18:01:07 -04:00
|
|
|
@NgModule({
|
|
|
|
providers: [
|
|
|
|
// TODO(pascal): use factory type annotations once supported in DI
|
|
|
|
// issue: https://github.com/angular/angular/issues/3183
|
|
|
|
{provide: Http, useFactory: httpFactory, deps: [XHRBackend, RequestOptions]},
|
|
|
|
BrowserXhr,
|
|
|
|
{provide: RequestOptions, useClass: BaseRequestOptions},
|
|
|
|
{provide: ResponseOptions, useClass: BaseResponseOptions},
|
|
|
|
XHRBackend,
|
|
|
|
{provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy},
|
|
|
|
],
|
|
|
|
})
|
2016-07-27 16:09:05 -04:00
|
|
|
export class HttpModule {
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The module that includes jsonp's providers
|
|
|
|
*
|
|
|
|
* @experimental
|
|
|
|
*/
|
2016-08-18 18:01:07 -04:00
|
|
|
@NgModule({
|
|
|
|
providers: [
|
|
|
|
// TODO(pascal): use factory type annotations once supported in DI
|
|
|
|
// issue: https://github.com/angular/angular/issues/3183
|
|
|
|
{provide: Jsonp, useFactory: jsonpFactory, deps: [JSONPBackend, RequestOptions]},
|
|
|
|
BrowserJsonp,
|
|
|
|
{provide: RequestOptions, useClass: BaseRequestOptions},
|
|
|
|
{provide: ResponseOptions, useClass: BaseResponseOptions},
|
|
|
|
{provide: JSONPBackend, useClass: JSONPBackend_},
|
|
|
|
],
|
|
|
|
})
|
2016-07-27 16:09:05 -04:00
|
|
|
export class JsonpModule {
|
|
|
|
}
|