UNPKG

2.02 kBTypeScriptView Raw
1import { HttpBackend, HttpEvent, HttpHeaders, HttpRequest, HttpResponse, HttpXhrBackend, XhrFactory } from '@angular/common/http';
2import { Observable } from 'rxjs';
3import { InMemoryBackendConfigArgs, InMemoryDbService, ResponseOptions } from './interfaces';
4import { BackendService } from './backend.service';
5/**
6 * For Angular `HttpClient` simulate the behavior of a RESTy web api
7 * backed by the simple in-memory data store provided by the injected `InMemoryDbService`.
8 * Conforms mostly to behavior described here:
9 * http://www.restapitutorial.com/lessons/httpmethods.html
10 *
11 * ### Usage
12 *
13 * Create an in-memory data store class that implements `InMemoryDbService`.
14 * Call `config` static method with this service class and optional configuration object:
15 * ```
16 * // other imports
17 * import { HttpClientModule } from '@angular/common/http';
18 * import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';
19 *
20 * import { InMemHeroService, inMemConfig } from '../api/in-memory-hero.service';
21 * @NgModule({
22 * imports: [
23 * HttpModule,
24 * HttpClientInMemoryWebApiModule.forRoot(InMemHeroService, inMemConfig),
25 * ...
26 * ],
27 * ...
28 * })
29 * export class AppModule { ... }
30 * ```
31 */
32export declare class HttpClientBackendService extends BackendService implements HttpBackend {
33 private xhrFactory;
34 constructor(inMemDbService: InMemoryDbService, config: InMemoryBackendConfigArgs, xhrFactory: XhrFactory);
35 handle(req: HttpRequest<any>): Observable<HttpEvent<any>>;
36 protected getJsonBody(req: HttpRequest<any>): any;
37 protected getRequestMethod(req: HttpRequest<any>): string;
38 protected createHeaders(headers: {
39 [index: string]: string;
40 }): HttpHeaders;
41 protected createQueryMap(search: string): Map<string, string[]>;
42 protected createResponse$fromResponseOptions$(resOptions$: Observable<ResponseOptions>): Observable<HttpResponse<any>>;
43 protected createPassThruBackend(): HttpXhrBackend;
44}