refactor(Http): rename request options interface

This commit is contained in:
Jeff Cross
2015-06-13 19:48:40 -07:00
parent 70ffd267f8
commit e68e69e7e5
5 changed files with 24 additions and 24 deletions
+9 -9
View File
@@ -1,7 +1,7 @@
/// <reference path="../../typings/rx/rx.all.d.ts" />
import {Injectable} from 'angular2/src/di/decorators';
import {RequestOptions, Connection} from './interfaces';
import {IRequestOptions, Connection} from './interfaces';
import {Request} from './static_request';
import {Response} from './static_response';
import {XHRBackend} from './backends/xhr_backend';
@@ -61,7 +61,7 @@ function httpRequest(backend: XHRBackend, request: Request) {
export class Http {
constructor(private backend: XHRBackend, private defaultOptions: BaseRequestOptions) {}
request(url: string|Request, options?: RequestOptions): Rx.Observable<Response> {
request(url: string | Request, options?: IRequestOptions): Rx.Observable<Response> {
if (typeof url === 'string') {
return httpRequest(this.backend, new Request(url, this.defaultOptions.merge(options)));
} else if (url instanceof Request) {
@@ -69,36 +69,36 @@ export class Http {
}
}
get(url: string, options?: RequestOptions) {
get(url: string, options?: IRequestOptions) {
return httpRequest(this.backend, new Request(url, this.defaultOptions.merge(options)
.merge({method: RequestMethods.GET})));
}
post(url: string, body: URLSearchParams | FormData | Blob | string, options?: RequestOptions) {
post(url: string, body: URLSearchParams | FormData | Blob | string, options?: IRequestOptions) {
return httpRequest(this.backend,
new Request(url, this.defaultOptions.merge(options)
.merge({body: body, method: RequestMethods.POST})));
}
put(url: string, body: URLSearchParams | FormData | Blob | string, options?: RequestOptions) {
put(url: string, body: URLSearchParams | FormData | Blob | string, options?: IRequestOptions) {
return httpRequest(this.backend,
new Request(url, this.defaultOptions.merge(options)
.merge({body: body, method: RequestMethods.PUT})));
}
delete (url: string, options?: RequestOptions) {
delete (url: string, options?: IRequestOptions) {
return httpRequest(this.backend, new Request(url, this.defaultOptions.merge(options)
.merge({method: RequestMethods.DELETE})));
}
patch(url: string, body: URLSearchParams | FormData | Blob | string, options?: RequestOptions) {
patch(url: string, body: URLSearchParams | FormData | Blob | string, options?: IRequestOptions) {
return httpRequest(this.backend,
new Request(url, this.defaultOptions.merge(options)
.merge({body: body, method: RequestMethods.PATCH})));
}
head(url: string, options?: RequestOptions) {
head(url: string, options?: IRequestOptions) {
return httpRequest(this.backend, new Request(url, this.defaultOptions.merge(options)
.merge({method: RequestMethods.HEAD})));
}
@@ -111,7 +111,7 @@ if (Rx.hasOwnProperty('default')) {
Observable = Rx.Observable;
}
export function HttpFactory(backend: XHRBackend, defaultOptions: BaseRequestOptions) {
return function(url: string | Request, options?: RequestOptions) {
return function(url: string | Request, options?: IRequestOptions) {
if (typeof url === 'string') {
return httpRequest(backend, new Request(url, defaultOptions.merge(options)));
} else if (url instanceof Request) {