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