refactor(http): use ngModules for http (#10329)
This commit is contained in:
parent
3b690b68a6
commit
422effdd18
|
@ -12,7 +12,7 @@
|
|||
* The http module provides services to perform http requests. To get started, see the {@link Http}
|
||||
* class.
|
||||
*/
|
||||
import {provide} from '@angular/core';
|
||||
import {NgModule} from '@angular/core';
|
||||
|
||||
import {BrowserJsonp} from './src/backends/browser_jsonp';
|
||||
import {BrowserXhr} from './src/backends/browser_xhr';
|
||||
|
@ -181,7 +181,7 @@ export {QueryEncoder, URLSearchParams} from './src/url_search_params';
|
|||
* .catch(err => console.error(err));
|
||||
* ```
|
||||
*
|
||||
* @experimental
|
||||
* @deprecated
|
||||
*/
|
||||
export const HTTP_PROVIDERS: any[] = [
|
||||
// TODO(pascal): use factory type annotations once supported in DI
|
||||
|
@ -191,9 +191,15 @@ export const HTTP_PROVIDERS: any[] = [
|
|||
{provide: RequestOptions, useClass: BaseRequestOptions},
|
||||
{provide: ResponseOptions, useClass: BaseResponseOptions},
|
||||
XHRBackend,
|
||||
{provide: XSRFStrategy, useValue: new CookieXSRFStrategy()},
|
||||
{provide: XSRFStrategy, useFactory: _createDefaultCookieXSRFStrategy},
|
||||
];
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
*/
|
||||
export function _createDefaultCookieXSRFStrategy() {
|
||||
return new CookieXSRFStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
|
@ -339,3 +345,21 @@ function jsonpFactory(jsonpBackend: JSONPBackend, requestOptions: RequestOptions
|
|||
* @deprecated
|
||||
*/
|
||||
export const JSON_BINDINGS = JSONP_PROVIDERS;
|
||||
|
||||
/**
|
||||
* The module that includes http's providers
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
@NgModule({providers: HTTP_PROVIDERS})
|
||||
export class HttpModule {
|
||||
}
|
||||
|
||||
/**
|
||||
* The module that includes jsonp's providers
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
@NgModule({providers: JSONP_PROVIDERS})
|
||||
export class JsonpModule {
|
||||
}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
/** @experimental */
|
||||
export declare function _createDefaultCookieXSRFStrategy(): CookieXSRFStrategy;
|
||||
|
||||
/** @experimental */
|
||||
export declare class BaseRequestOptions extends RequestOptions {
|
||||
constructor();
|
||||
|
@ -70,12 +73,16 @@ export declare class Http {
|
|||
/** @deprecated */
|
||||
export declare const HTTP_BINDINGS: any[];
|
||||
|
||||
/** @experimental */
|
||||
/** @deprecated */
|
||||
export declare const HTTP_PROVIDERS: any[];
|
||||
|
||||
/** @experimental */
|
||||
export declare function httpFactory(xhrBackend: XHRBackend, requestOptions: RequestOptions): Http;
|
||||
|
||||
/** @experimental */
|
||||
export declare class HttpModule {
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
export declare const JSON_BINDINGS: any[];
|
||||
|
||||
|
@ -100,6 +107,10 @@ export declare abstract class JSONPConnection implements Connection {
|
|||
abstract finished(data?: any): void;
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare class JsonpModule {
|
||||
}
|
||||
|
||||
/** @experimental */
|
||||
export declare class QueryEncoder {
|
||||
encodeKey(k: string): string;
|
||||
|
|
Loading…
Reference in New Issue