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.
|
|
|
|
*/
|
|
|
|
import {bind, Binding} from 'angular2/di';
|
2015-08-20 17:28:25 -04:00
|
|
|
import {Http, Jsonp} from './src/http/http';
|
|
|
|
import {XHRBackend, XHRConnection} from './src/http/backends/xhr_backend';
|
|
|
|
import {JSONPBackend, JSONPConnection} from './src/http/backends/jsonp_backend';
|
|
|
|
import {BrowserXhr} from './src/http/backends/browser_xhr';
|
|
|
|
import {BrowserJsonp} from './src/http/backends/browser_jsonp';
|
|
|
|
import {BaseRequestOptions, RequestOptions} from './src/http/base_request_options';
|
|
|
|
import {ConnectionBackend} from './src/http/interfaces';
|
|
|
|
import {BaseResponseOptions, ResponseOptions} from './src/http/base_response_options';
|
2015-07-28 16:10:25 -04:00
|
|
|
|
2015-08-20 17:28:25 -04:00
|
|
|
export {MockConnection, MockBackend} from './src/http/backends/mock_backend';
|
|
|
|
export {Request} from './src/http/static_request';
|
|
|
|
export {Response} from './src/http/static_response';
|
2015-07-28 16:10:25 -04:00
|
|
|
|
|
|
|
export {
|
2015-08-11 18:01:29 -04:00
|
|
|
RequestOptionsArgs,
|
|
|
|
ResponseOptionsArgs,
|
2015-07-28 16:10:25 -04:00
|
|
|
Connection,
|
|
|
|
ConnectionBackend
|
2015-08-20 17:28:25 -04:00
|
|
|
} from './src/http/interfaces';
|
2015-07-28 16:10:25 -04:00
|
|
|
|
2015-08-20 17:28:25 -04:00
|
|
|
export {BrowserXhr} from './src/http/backends/browser_xhr';
|
|
|
|
export {BaseRequestOptions, RequestOptions} from './src/http/base_request_options';
|
|
|
|
export {BaseResponseOptions, ResponseOptions} from './src/http/base_response_options';
|
|
|
|
export {XHRBackend, XHRConnection} from './src/http/backends/xhr_backend';
|
|
|
|
export {JSONPBackend, JSONPConnection} from './src/http/backends/jsonp_backend';
|
|
|
|
export {Http, Jsonp} from './src/http/http';
|
2015-07-28 16:10:25 -04:00
|
|
|
|
2015-08-20 17:28:25 -04:00
|
|
|
export {Headers} from './src/http/headers';
|
2015-07-28 16:10:25 -04:00
|
|
|
|
|
|
|
export {
|
|
|
|
ResponseTypes,
|
|
|
|
ReadyStates,
|
|
|
|
RequestMethods,
|
|
|
|
RequestCredentialsOpts,
|
|
|
|
RequestCacheOpts,
|
|
|
|
RequestModesOpts
|
2015-08-25 13:11:28 -04:00
|
|
|
} from './src/http/enums';
|
|
|
|
export {URLSearchParams} from './src/http/url_search_params';
|
2015-07-28 16:10:25 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provides a basic set of injectables to use the {@link Http} service in any application.
|
|
|
|
*
|
|
|
|
* #Example
|
|
|
|
*
|
|
|
|
* ```
|
2015-08-11 00:42:47 -04:00
|
|
|
* import {HTTP_BINDINGS, Http} from 'http/http';
|
|
|
|
* @Component({selector: 'http-app', viewBindings: [HTTP_BINDINGS]})
|
2015-07-28 16:10:25 -04:00
|
|
|
* @View({template: '{{data}}'})
|
|
|
|
* class MyApp {
|
|
|
|
* constructor(http:Http) {
|
|
|
|
* http.request('data.txt').subscribe(res => this.data = res.text());
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
* ```
|
|
|
|
*
|
|
|
|
*/
|
2015-08-28 14:29:19 -04:00
|
|
|
export const HTTP_BINDINGS: any[] = [
|
2015-07-30 10:29:16 -04:00
|
|
|
// TODO(pascal): use factory type annotations once supported in DI
|
|
|
|
// issue: https://github.com/angular/angular/issues/3183
|
|
|
|
bind(Http)
|
|
|
|
.toFactory((xhrBackend, requestOptions) => { return new Http(xhrBackend, requestOptions);},
|
|
|
|
[XHRBackend, RequestOptions]),
|
2015-07-28 16:10:25 -04:00
|
|
|
BrowserXhr,
|
|
|
|
bind(RequestOptions).toClass(BaseRequestOptions),
|
|
|
|
bind(ResponseOptions).toClass(BaseResponseOptions),
|
2015-07-30 10:29:16 -04:00
|
|
|
XHRBackend
|
2015-07-28 16:10:25 -04:00
|
|
|
];
|
|
|
|
|
2015-08-28 14:29:19 -04:00
|
|
|
export const JSONP_BINDINGS: any[] = [
|
2015-07-30 10:29:16 -04:00
|
|
|
// TODO(pascal): use factory type annotations once supported in DI
|
|
|
|
// issue: https://github.com/angular/angular/issues/3183
|
|
|
|
bind(Jsonp)
|
|
|
|
.toFactory(
|
|
|
|
(jsonpBackend, requestOptions) => { return new Jsonp(jsonpBackend, requestOptions);},
|
|
|
|
[JSONPBackend, RequestOptions]),
|
2015-07-28 16:10:25 -04:00
|
|
|
BrowserJsonp,
|
|
|
|
bind(RequestOptions).toClass(BaseRequestOptions),
|
|
|
|
bind(ResponseOptions).toClass(BaseResponseOptions),
|
2015-07-30 10:29:16 -04:00
|
|
|
JSONPBackend
|
2015-07-28 16:10:25 -04:00
|
|
|
];
|