diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-24 16:14:23 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-24 16:14:23 +0200 |
commit | 1c8206f8c0c8921643aa1b070fbe6648411300fe (patch) | |
tree | 1ee523e701fa369d0290d14e50a6f0b3cb5fb50f /src/http.ts | |
parent | fc53a08bb0ffaf2bd49408f50701f17cdd603fb9 (diff) |
remove dead code and add comments
Diffstat (limited to 'src/http.ts')
-rw-r--r-- | src/http.ts | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/http.ts b/src/http.ts index 5e6580016..965a44a97 100644 --- a/src/http.ts +++ b/src/http.ts @@ -16,23 +16,22 @@ /** * Helpers for doing XMLHttpRequest-s that are based on ES6 promises. - * @module Http - * @author Florian Dold + * Allows for easy mocking for test cases. */ -"use strict"; - +/** + * An HTTP response that is returned by all request methods of this library. + */ export interface HttpResponse { status: number; responseText: string; } +/** + * The request library is bundled into an interface to make mocking easy. + */ export interface HttpRequestLibrary { - req(method: string, - url: string, - options?: any): Promise<HttpResponse>; - get(url: string): Promise<HttpResponse>; postJson(url: string, body: any): Promise<HttpResponse>; @@ -41,8 +40,12 @@ export interface HttpRequestLibrary { } +/** + * An implementation of the [[HttpRequestLibrary]] using the + * browser's XMLHttpRequest. + */ export class BrowserHttpLib { - req(method: string, + private req(method: string, url: string, options?: any): Promise<HttpResponse> { return new Promise<HttpResponse>((resolve, reject) => { @@ -82,8 +85,10 @@ export class BrowserHttpLib { } +/** + * Exception thrown on request errors. + */ export class RequestException { - constructor(detail: any) { - + constructor(public detail: any) { } } |